#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, j;
  volatile int k;
  printf("\nsig_int starting\n");
  for (i = 0; i < 300000; i++)
    for (j = 0; j < 4000; j++)
      k += i * j;
  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   $0x493e0,-0x8(%rbp)
jge    117f <sig_int+0x6f>
movl   $0x0,-0xc(%rbp)
cmpl   $0xfa0,-0xc(%rbp)
jge    116c <sig_int+0x5c>
mov    -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1142 <sig_int+0x32>
jmp    1171 <sig_int+0x61>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112e <sig_int+0x1e>
lea    0xe8d(%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>
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %r10d,%r10d
xor    %esi,%esi
xor    %edi,%edi
nopw   0x0(%rax,%rax,1)
mov    $0xfa0,%eax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
add    %ecx,0x4(%rsp)
lea    (%rdi,%rcx,1),%edx
add    %edx,0x4(%rsp)
lea    (%r8,%rcx,1),%edx
add    %edx,0x4(%rsp)
lea    (%r9,%rcx,1),%edx
add    %edx,0x4(%rsp)
lea    (%rsi,%rcx,1),%edx
add    %edx,0x4(%rsp)
add    %r10d,%ecx
add    $0xfffffffb,%eax
jne    1140 <sig_int+0x30>
add    $0x1,%edi
add    $0x4,%esi
add    $0x5,%r10d
add    $0x3,%r9d
add    $0x2,%r8d
cmp    $0x493e0,%edi
jne    1130 <sig_int+0x20>
lea    0xe87(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"\0Asig_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
%5 = alloca i32
store i32 %0, i32* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %24, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 300000
br i1 %9, label %10, label %27
10: ; preds = %7
store i32 0, i32* %4
br label %11
11: ; preds = %20, %10
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 4000
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = mul nsw i32 %15, %16
%18 = load volatile i32, i32* %5
%19 = add nsw i32 %18, %17
store volatile i32 %19, i32* %5
br label %20
20: ; preds = %14
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %11
23: ; preds = %11
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %7
27: ; preds = %7
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [18 x i8] c"\0Asig_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 ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %1, %30
%6 = phi i32 [ 0, %1 ], [ %31, %30 ]
br label %7
7: ; preds = %7, %5
%8 = phi i32 [ 0, %5 ], [ %28, %7 ]
%9 = mul nuw nsw i32 %8, %6
%10 = load volatile i32, i32* %2
%11 = add nsw i32 %10, %9
store volatile i32 %11, i32* %2
%12 = add nuw nsw i32 %8, 1
%13 = mul nuw nsw i32 %12, %6
%14 = load volatile i32, i32* %2
%15 = add nsw i32 %14, %13
store volatile i32 %15, i32* %2
%16 = add nuw nsw i32 %8, 2
%17 = mul nuw nsw i32 %16, %6
%18 = load volatile i32, i32* %2
%19 = add nsw i32 %18, %17
store volatile i32 %19, i32* %2
%20 = add nuw nsw i32 %8, 3
%21 = mul nuw nsw i32 %20, %6
%22 = load volatile i32, i32* %2
%23 = add nsw i32 %22, %21
store volatile i32 %23, i32* %2
%24 = add nuw nsw i32 %8, 4
%25 = mul nuw nsw i32 %24, %6
%26 = load volatile i32, i32* %2
%27 = add nsw i32 %26, %25
store volatile i32 %27, i32* %2
%28 = add nuw nsw i32 %8, 5
%29 = icmp eq i32 %28, 4000
br i1 %29, label %30, label %7
30: ; preds = %7
%31 = add nuw nsw i32 %6, 1
%32 = icmp eq i32 %31, 300000
br i1 %32, label %33, label %5
33: ; preds = %30
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.2, i64 0, i64 0))
ret void
}