Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions projects/hw2.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
; ModuleID = 'hw2.c'
source_filename = "hw2.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@main.a = private unnamed_addr constant [8 x i32] [i32 -83, i32 231, i32 -200, i32 70, i32 -77, i32 154, i32 77, i32 -91], align 16
@.str = private unnamed_addr constant [4 x i8] c"%c\0A\00", align 1

; Function Attrs: noinline nounwind optnone uwtable
define i32 @main() #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
%3 = alloca i32, align 4
%4 = alloca [8 x i32], align 16
%5 = alloca i32, align 4
store i32 0, i32* %1, align 4
store i32 0, i32* %2, align 4
store i32 0, i32* %3, align 4
%6 = bitcast [8 x i32]* %4 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %6, i8* bitcast ([8 x i32]* @main.a to i8*), i64 32, i32 16, i1 false)
store i32 1, i32* %5, align 4
store i32 0, i32* %2, align 4
br label %7

; <label>:7: ; preds = %30, %0
%8 = load i32, i32* %2, align 4
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %33

; <label>:10: ; preds = %7
%11 = load i32, i32* %5, align 4
%12 = load i32, i32* %2, align 4
%13 = load i32, i32* %3, align 4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %14
%16 = load i32, i32* %15, align 4
%17 = mul nsw i32 %12, %16
%18 = add nsw i32 %11, %17
%19 = load i32, i32* %3, align 4
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %21
%23 = load i32, i32* %22, align 4
%24 = add nsw i32 %18, %23
store i32 %24, i32* %5, align 4
%25 = load i32, i32* %5, align 4
%26 = sdiv i32 %25, 2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %26)
%28 = load i32, i32* %3, align 4
%29 = add nsw i32 %28, 2
store i32 %29, i32* %3, align 4
br label %30

; <label>:30: ; preds = %10
%31 = load i32, i32* %2, align 4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2, align 4
br label %7

; <label>:33: ; preds = %7
%34 = load i32, i32* %1, align 4
ret i32 %34
}

; Function Attrs: argmemonly nounwind
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1

declare i32 @printf(i8*, ...) #2

attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { argmemonly nounwind }
attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)"}