#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);
int main(int argc, char *argv[]) {
  int i;
  int sum = 0;
  for (i = 0; i < argc; i++) {
    sum += i;
  }
  for (i = 1; i <= 4; i++) {
    sum += sum;
  }
  printf("Sum is: %d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1157 <main+0x47>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <main+0x24>
movl   $0x1,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jg     117f <main+0x6f>
mov    -0x18(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <main+0x4e>
mov    -0x18(%rbp),%esi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
test   %edi,%edi
jle    112c <main+0x1c>
lea    -0x1(%rdi),%eax
lea    -0x2(%rdi),%ecx
imul   %eax,%ecx
lea    (%rcx,%rdi,2),%eax
lea    -0x10(,%rax,8),%esi
and    $0xfffffff0,%esi
jmp    112e <main+0x1e>
xor    %esi,%esi
push   %rax
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Sum is: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %6
br label %8
8: ; preds = %16, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = add nsw i32 %14, %13
store i32 %15, i32* %7
br label %16
16: ; preds = %12
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %8
19: ; preds = %8
store i32 1, i32* %6
br label %20
20: ; preds = %27, %19
%21 = load i32, i32* %6
%22 = icmp sle i32 %21, 4
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32, i32* %7
%25 = load i32, i32* %7
%26 = add nsw i32 %25, %24
store i32 %26, i32* %7
br label %27
27: ; preds = %23
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %20
30: ; preds = %20
%31 = load i32, i32* %7
%32 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Sum is: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = add nsw i32 %0, -1
%6 = add nsw i32 %0, -2
%7 = mul i32 %5, %6
%8 = shl nuw i32 %0, 1
%9 = add i32 %7, %8
%10 = shl i32 %9, 3
%11 = add i32 %10, -16
%12 = and i32 %11, -16
br label %13
13: ; preds = %4, %2
%14 = phi i32 [ 0, %2 ], [ %12, %4 ]
%15 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %14)
ret i32 0
}