#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 *);
void sig_int(int signo) {
  int i;
  volatile int j;
  printf("\nsign_int starting\n");
  for (i = 0; i < 2000000; i++) {
    j += i * i;
  }
  printf("sig_int finished\n");
}


x86 assembly (clang, -O0):
<sig_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x1e8480,-0x8(%rbp)
jge    1158 <sig_int+0x48>
mov    -0x8(%rbp),%ecx
imul   -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112e <sig_int+0x1e>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_int>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x4(%rax),%ecx
imul   %ecx,%ecx
add    %ecx,0x4(%rsp)
lea    -0x3(%rax),%ecx
imul   %ecx,%ecx
add    %ecx,0x4(%rsp)
lea    -0x2(%rax),%ecx
imul   %ecx,%ecx
add    %ecx,0x4(%rsp)
lea    -0x1(%rax),%ecx
imul   %ecx,%ecx
add    %ecx,0x4(%rsp)
mov    %eax,%ecx
imul   %eax,%ecx
add    %ecx,0x4(%rsp)
add    $0x5,%eax
cmp    $0x1e8484,%eax
jne    1130 <sig_int+0x20>
lea    0xea1(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"\0Asign_int starting\0A\00"
@.str.1 = [18 x i8] c"sig_int finished\0A\00"
define void @sig_int(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %6
6: ; preds = %15, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 2000000
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = mul nsw i32 %10, %11
%13 = load volatile i32, i32* %4
%14 = add nsw i32 %13, %12
store volatile i32 %14, i32* %4
br label %15
15: ; preds = %9
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %6
18: ; preds = %6
%19 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [19 x i8] c"\0Asign_int starting\00"
@str.2 = [17 x i8] c"sig_int finished\00"
define void @sig_int(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %5, %1
%6 = phi i32 [ 0, %1 ], [ %26, %5 ]
%7 = mul nsw i32 %6, %6
%8 = load volatile i32, i32* %2
%9 = add nsw i32 %8, %7
store volatile i32 %9, i32* %2
%10 = add nuw nsw i32 %6, 1
%11 = mul nsw i32 %10, %10
%12 = load volatile i32, i32* %2
%13 = add nsw i32 %12, %11
store volatile i32 %13, i32* %2
%14 = add nuw nsw i32 %6, 2
%15 = mul nsw i32 %14, %14
%16 = load volatile i32, i32* %2
%17 = add nsw i32 %16, %15
store volatile i32 %17, i32* %2
%18 = add nuw nsw i32 %6, 3
%19 = mul nsw i32 %18, %18
%20 = load volatile i32, i32* %2
%21 = add nsw i32 %20, %19
store volatile i32 %21, i32* %2
%22 = add nuw nsw i32 %6, 4
%23 = mul nsw i32 %22, %22
%24 = load volatile i32, i32* %2
%25 = add nsw i32 %24, %23
store volatile i32 %25, i32* %2
%26 = add nuw nsw i32 %6, 5
%27 = icmp eq i32 %26, 2000000
br i1 %27, label %28, label %5
28: ; preds = %5
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.2, i64 0, i64 0))
ret void
}