#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, j;
  int sum = 0;
  for (i = 0; i < 127; i++) {
    for (j = 0; j < argv[1][0]; j++) {
      sum += j;
    }
  }
  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,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x7f,-0x14(%rbp)
jge    1185 <main+0x75>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jge    1172 <main+0x62>
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <main+0x35>
jmp    1177 <main+0x67>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <main+0x24>
mov    -0x1c(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rax
movsbl (%rax),%edx
lea    -0x1(%rdx),%eax
lea    -0x2(%rdx),%esi
imul   %rax,%rsi
shr    %rsi
xor    %ecx,%ecx
lea    (%rdx,%rsi,1),%eax
add    $0xffffffff,%eax
test   %edx,%edx
jg     1137 <main+0x27>
pxor   %xmm0,%xmm0
jmp    114d <main+0x3d>
movd   %eax,%xmm0
movdqa %xmm0,%xmm1
pslld  $0x5,%xmm1
psubd  %xmm0,%xmm1
pshufd $0x0,%xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
cmovle %ecx,%eax
movd   %xmm0,%esi
add    %eax,%esi
add    %eax,%esi
add    %eax,%esi
lea    0xe8d(%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
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %6
br label %9
9: ; preds = %30, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 127
br i1 %11, label %12, label %33
12: ; preds = %9
store i32 0, i32* %7
br label %13
13: ; preds = %26, %12
%14 = load i32, i32* %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp slt i32 %14, %20
br i1 %21, label %22, label %29
22: ; preds = %13
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = add nsw i32 %24, %23
store i32 %25, i32* %8
br label %26
26: ; preds = %22
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %13
29: ; preds = %13
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %9
33: ; preds = %9
%34 = load i32, i32* %8
%35 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Sum is: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp sgt i8 %5, 0
%8 = add nsw i32 %6, -1
%9 = zext i32 %8 to i33
%10 = add nsw i32 %6, -2
%11 = zext i32 %10 to i33
%12 = mul i33 %9, %11
%13 = lshr i33 %12, 1
%14 = trunc i33 %13 to i32
%15 = add i32 %6, %14
%16 = add i32 %15, -1
%17 = insertelement <4 x i32> poison, i32 %16, i64 0
%18 = mul <4 x i32> %17, <i32 31, i32 poison, i32 poison, i32 poison>
%19 = shufflevector <4 x i32> %18, <4 x i32> poison, <4 x i32> zeroinitializer
%20 = select i1 %7, <4 x i32> %19, <4 x i32> zeroinitializer
%21 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %20)
%22 = select i1 %7, i32 %16, i32 0
%23 = add i32 %21, %22
%24 = select i1 %7, i32 %16, i32 0
%25 = add i32 %23, %24
%26 = select i1 %7, i32 %16, i32 0
%27 = add i32 %25, %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %27)
ret i32 0
}