#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int counter, largest, num;
  printf("for Loop Example 4\n\n");
  for (counter = 1; counter <= 8; counter++) {
    printf("Enter a number: ");
    scanf("%d", &num);
    if (counter == 1) {
      printf("First value; largest by default.\n");
      largest = num;
    } else if (num == largest)
      printf("Your number is the same as the largest.\n");
    else if (num > largest) {
      printf("Your number is the new largest!\n");
      largest = num;
    } else
      printf("Your number is smaller than the largest.\n");
  }
  printf("\nThe largest number you entered was %d.\n", largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jg     11fe <main+0xde>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    118f <main+0x6f>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11eb <main+0xcb>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11ae <main+0x8e>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e6 <main+0xc6>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11d3 <main+0xb3>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11e1 <main+0xc1>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e6 <main+0xc6>
jmp    11eb <main+0xcb>
jmp    11f0 <main+0xd0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <main+0x24>
mov    -0xc(%rbp),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rbx
lea    0x4(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
lea    0xf50(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%r15d
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
cmp    %r15d,0x4(%rsp)
jne    11a1 <main+0x71>
lea    0xefb(%rip),%rdi
jmp    11bd <main+0x8d>
jle    11b6 <main+0x86>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%r15d
jmp    11c2 <main+0x92>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    %r15d,0x4(%rsp)
jne    11f1 <main+0xc1>
lea    0xeab(%rip),%rdi
jmp    120d <main+0xdd>
jle    1206 <main+0xd6>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%r15d
jmp    1212 <main+0xe2>
lea    0xe44(%rip),%rdi
call   1030 <puts@plt>
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdea(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    %r15d,0x4(%rsp)
jne    1241 <main+0x111>
lea    0xe5b(%rip),%rdi
jmp    125d <main+0x12d>
jle    1256 <main+0x126>
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%r15d
jmp    1262 <main+0x132>
lea    0xdf4(%rip),%rdi
call   1030 <puts@plt>
lea    0xd97(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd9a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    %r15d,0x4(%rsp)
jne    1291 <main+0x161>
lea    0xe0b(%rip),%rdi
jmp    12ad <main+0x17d>
jle    12a6 <main+0x176>
lea    0xde0(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%r15d
jmp    12b2 <main+0x182>
lea    0xda4(%rip),%rdi
call   1030 <puts@plt>
lea    0xd47(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd4a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    %r15d,0x4(%rsp)
jne    12e1 <main+0x1b1>
lea    0xdbb(%rip),%rdi
jmp    12fd <main+0x1cd>
jle    12f6 <main+0x1c6>
lea    0xd90(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%r15d
jmp    1302 <main+0x1d2>
lea    0xd54(%rip),%rdi
call   1030 <puts@plt>
lea    0xcf7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcfa(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    %r15d,0x4(%rsp)
jne    1331 <main+0x201>
lea    0xd6b(%rip),%rdi
jmp    134d <main+0x21d>
jle    1346 <main+0x216>
lea    0xd40(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%r15d
jmp    1352 <main+0x222>
lea    0xd04(%rip),%rdi
call   1030 <puts@plt>
lea    0xca7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcaa(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    %r15d,0x4(%rsp)
jne    1381 <main+0x251>
lea    0xd1b(%rip),%rdi
jmp    139d <main+0x26d>
jle    1396 <main+0x266>
lea    0xcf0(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%r15d
jmp    13a2 <main+0x272>
lea    0xcb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xc6b(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"for Loop Example 4\0A\0A\00"
@.str.1 = [17 x i8] c"Enter a number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [34 x i8] c"First value; largest by default.\0A\00"
@.str.4 = [41 x i8] c"Your number is the same as the largest.\0A\00"
@.str.5 = [33 x i8] c"Your number is the new largest!\0A\00"
@.str.6 = [42 x i8] c"Your number is smaller than the largest.\0A\00"
@.str.7 = [41 x i8] c"\0AThe largest number you entered was %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %6
6: ; preds = %35, %0
%7 = load i32, i32* %2
%8 = icmp sle i32 %7, 8
br i1 %8, label %9, label %38
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* %4
store i32 %16, i32* %3
br label %34
17: ; preds = %9
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
br label %33
23: ; preds = %17
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%29 = load i32, i32* %4
store i32 %29, i32* %3
br label %32
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
br label %33
33: ; preds = %32, %21
br label %34
34: ; preds = %33, %14
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %6
38: ; preds = %6
%39 = load i32, i32* %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [17 x i8] c"Enter a number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.7 = [41 x i8] c"\0AThe largest number you entered was %d.\0A\00"
@str = [20 x i8] c"for Loop Example 4\0A\00"
@str.8 = [41 x i8] c"Your number is smaller than the largest.\00"
@str.9 = [32 x i8] c"Your number is the new largest!\00"
@str.10 = [40 x i8] c"Your number is the same as the largest.\00"
@str.11 = [33 x i8] c"First value; largest by default.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.11, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, %7
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
br label %21
14: ; preds = %0
%15 = icmp sgt i32 %10, %7
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%18 = load i32, i32* %1
br label %21
19: ; preds = %14
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
br label %21
21: ; preds = %16, %19, %12
%22 = phi i32 [ %7, %12 ], [ %18, %16 ], [ %7, %19 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, %22
br i1 %26, label %34, label %27
27: ; preds = %21
%28 = icmp sgt i32 %25, %22
br i1 %28, label %31, label %29
29: ; preds = %27
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
br label %36
31: ; preds = %27
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%33 = load i32, i32* %1
br label %36
34: ; preds = %21
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
br label %36
36: ; preds = %34, %31, %29
%37 = phi i32 [ %22, %34 ], [ %33, %31 ], [ %22, %29 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%40 = load i32, i32* %1
%41 = icmp eq i32 %40, %37
br i1 %41, label %49, label %42
42: ; preds = %36
%43 = icmp sgt i32 %40, %37
br i1 %43, label %46, label %44
44: ; preds = %42
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
br label %51
46: ; preds = %42
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%48 = load i32, i32* %1
br label %51
49: ; preds = %36
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
br label %51
51: ; preds = %49, %46, %44
%52 = phi i32 [ %37, %49 ], [ %48, %46 ], [ %37, %44 ]
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%54 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%55 = load i32, i32* %1
%56 = icmp eq i32 %55, %52
br i1 %56, label %64, label %57
57: ; preds = %51
%58 = icmp sgt i32 %55, %52
br i1 %58, label %61, label %59
59: ; preds = %57
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
br label %66
61: ; preds = %57
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%63 = load i32, i32* %1
br label %66
64: ; preds = %51
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
br label %66
66: ; preds = %64, %61, %59
%67 = phi i32 [ %52, %64 ], [ %63, %61 ], [ %52, %59 ]
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%69 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%70 = load i32, i32* %1
%71 = icmp eq i32 %70, %67
br i1 %71, label %79, label %72
72: ; preds = %66
%73 = icmp sgt i32 %70, %67
br i1 %73, label %76, label %74
74: ; preds = %72
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
br label %81
76: ; preds = %72
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%78 = load i32, i32* %1
br label %81
79: ; preds = %66
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
br label %81
81: ; preds = %79, %76, %74
%82 = phi i32 [ %67, %79 ], [ %78, %76 ], [ %67, %74 ]
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%84 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%85 = load i32, i32* %1
%86 = icmp eq i32 %85, %82
br i1 %86, label %94, label %87
87: ; preds = %81
%88 = icmp sgt i32 %85, %82
br i1 %88, label %91, label %89
89: ; preds = %87
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
br label %96
91: ; preds = %87
%92 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%93 = load i32, i32* %1
br label %96
94: ; preds = %81
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
br label %96
96: ; preds = %94, %91, %89
%97 = phi i32 [ %82, %94 ], [ %93, %91 ], [ %82, %89 ]
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%99 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%100 = load i32, i32* %1
%101 = icmp eq i32 %100, %97
br i1 %101, label %109, label %102
102: ; preds = %96
%103 = icmp sgt i32 %100, %97
br i1 %103, label %106, label %104
104: ; preds = %102
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
br label %111
106: ; preds = %102
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%108 = load i32, i32* %1
br label %111
109: ; preds = %96
%110 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
br label %111
111: ; preds = %109, %106, %104
%112 = phi i32 [ %97, %109 ], [ %108, %106 ], [ %97, %104 ]
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i32 %112)
ret i32 0
}