#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 NSIG;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ signal(int, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int main(int argc, char *argv[]) {
  int i;
  for (i = 0; i < NSIG; i++) {
    signal(i, SIG_IGN);
  }
  while (1) {
    sleep(1);
    printf("lalala. Still running.\n");
  }
}


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,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e81(%rip),%rcx
cmp    (%rcx),%eax
jge    117e <main+0x4e>
mov    -0x14(%rbp),%edi
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
call   1040 <signal@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
jmp    1183 <main+0x53>
mov    $0x1,%edi
call   1050 <sleep@plt>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
jmp    1183 <main+0x53>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e9c(%rip),%r14
cmpl   $0x0,(%r14)
jle    1162 <main+0x32>
xor    %ebx,%ebx
mov    0x2e9d(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    (%r15),%esi
mov    %ebx,%edi
call   1040 <signal@plt>
add    $0x1,%ebx
cmp    (%r14),%ebx
jl     1150 <main+0x20>
lea    0xe97(%rip),%rbx
nopl   0x0(%rax)
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
jmp    1170 <main+0x40>

LLVM IR (-O0):
@NSIG = global i32 0
@SIG_IGN = global i32 0
@.str = [24 x i8] c"lalala. Still running.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %7
7: ; preds = %15, %2
%8 = load i32, i32* %6
%9 = load i32, i32* @NSIG
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i32, i32* %6
%13 = load i32, i32* @SIG_IGN
%14 = call i32 @signal(i32 %12, i32 %13)
br label %15
15: ; preds = %11
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %7
18: ; preds = %7
br label %19
19: ; preds = %18, %19
%20 = call i32 @sleep(i32 1)
%21 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %19
}

LLVM IR (-O2):
@NSIG = global i32 0
@SIG_IGN = global i32 0
@str = [23 x i8] c"lalala. Still running.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @NSIG
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2, %5
%6 = phi i32 [ %9, %5 ], [ 0, %2 ]
%7 = load i32, i32* @SIG_IGN
%8 = tail call i32 @signal(i32 %6, i32 %7)
%9 = add nuw nsw i32 %6, 1
%10 = load i32, i32* @NSIG
%11 = icmp slt i32 %9, %10
br i1 %11, label %5, label %12
12: ; preds = %5, %2
br label %13
13: ; preds = %12, %13
%14 = tail call i32 @sleep(i32 1)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %13
}