#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 EXIT_SUCCESS;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, size_t);
int /*<<< orphan*/ signal(int, int /*<<< orphan*/);
int main(void) {
  int i;
  size_t square;
  i = 0;
  while (++i < 31) {
    signal(i, SIG_IGN);
  }
  square = 2;
  close(0);
  while (1) {
    printf("%zd\n", square);
    square *= square;
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x1f,%eax
jge    116e <main+0x3e>
mov    -0x8(%rbp),%edi
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
jmp    1146 <main+0x16>
movq   $0x2,-0x10(%rbp)
xor    %edi,%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x10(%rbp)
jmp    117d <main+0x4d>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
mov    0x2ea8(%rip),%r14
mov    (%r14),%esi
mov    %ebx,%edi
call   1050 <signal@plt>
add    $0x1,%ebx
cmp    $0x1f,%ebx
jne    1140 <main+0x10>
xor    %edi,%edi
call   1040 <close@plt>
mov    $0x2,%ebx
lea    0xe9b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
imul   %rbx,%rbx
jmp    1170 <main+0x40>

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

LLVM IR (-O2):
@SIG_IGN = global i32 0
@.str = [5 x i8] c"%zd\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 1, %0 ], [ %5, %1 ]
%3 = load i32, i32* @SIG_IGN
%4 = tail call i32 @signal(i32 %2, i32 %3)
%5 = add nuw nsw i32 %2, 1
%6 = icmp eq i32 %5, 31
br i1 %6, label %7, label %1
7: ; preds = %1
%8 = tail call i32 @close(i32 0)
br label %9
9: ; preds = %9, %7
%10 = phi i64 [ 2, %7 ], [ %12, %9 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %10)
%12 = mul i64 %10, %10
br label %9
}