#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 main(void) {
  printf("# handler\n");
  printf(".text\n");
  printf(".globl __alltraps\n");
  int i;
  for (i = 0; i < 256; i++) {
    printf(".globl vector%d\n", i);
    printf("vector%d:\n", i);
    if ((i < 8 || i > 14) && i != 17) {
      printf("  pushq $0\n");
    }
    printf("  pushq $%d\n", i);
    printf("  jmp __alltraps\n");
  }
  printf("\n");
  printf("# vector table\n");
  printf(".data\n");
  printf(".globl __vectors\n");
  printf("__vectors:\n");
  for (i = 0; i < 256; i++) {
    printf("  .quad vector%d\n", i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    11d8 <main+0xc8>
mov    -0x8(%rbp),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x8,-0x8(%rbp)
jl     1193 <main+0x83>
cmpl   $0xe,-0x8(%rbp)
jle    11ab <main+0x9b>
cmpl   $0x11,-0x8(%rbp)
je     11ab <main+0x9b>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1150 <main+0x40>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1251 <main+0x141>
mov    -0x8(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1225 <main+0x115>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xef9(%rip),%rdi
call   1040 <puts@plt>
lea    0xef7(%rip),%rdi
call   1040 <puts@plt>
lea    0xef1(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9a(%rip),%r14
lea    0xea4(%rip),%r15
lea    0xea8(%rip),%r12
lea    0xf13(%rip),%rbx
lea    0xf1d(%rip),%r13
xor    %ebp,%ebp
jmp    11af <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     11de <main+0xae>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x8(%rbp),%eax
cmp    $0x7,%eax
jb     1190 <main+0x60>
cmp    $0x11,%ebp
je     1190 <main+0x60>
mov    %r13,%rdi
call   1040 <puts@plt>
jmp    1190 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe71(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe70(%rip),%rdi
call   1040 <puts@plt>
lea    0xe0a(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    1230 <main+0x100>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"# handler\0A\00"
@.str.1 = [7 x i8] c".text\0A\00"
@.str.2 = [19 x i8] c".globl __alltraps\0A\00"
@.str.3 = [17 x i8] c".globl vector%d\0A\00"
@.str.4 = [11 x i8] c"vector%d:\0A\00"
@.str.5 = [12 x i8] c" pushq $0\0A\00"
@.str.6 = [13 x i8] c" pushq $%d\0A\00"
@.str.7 = [18 x i8] c" jmp __alltraps\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [16 x i8] c"# vector table\0A\00"
@.str.10 = [7 x i8] c".data\0A\00"
@.str.11 = [18 x i8] c".globl __vectors\0A\00"
@.str.12 = [12 x i8] c"__vectors:\0A\00"
@.str.13 = [18 x i8] c" .quad vector%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %6
6: ; preds = %28, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 256
br i1 %8, label %9, label %31
9: ; preds = %6
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 8
br i1 %15, label %19, label %16
16: ; preds = %9
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 14
br i1 %18, label %19, label %24
19: ; preds = %16, %9
%20 = load i32, i32* %2
%21 = icmp ne i32 %20, 17
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %24
24: ; preds = %22, %19, %16
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %24
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %6
31: ; preds = %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %2
br label %37
37: ; preds = %43, %31
%38 = load i32, i32* %2
%39 = icmp slt i32 %38, 256
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = load i32, i32* %2
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %37
46: ; preds = %37
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [17 x i8] c".globl vector%d\0A\00"
@.str.4 = [11 x i8] c"vector%d:\0A\00"
@.str.6 = [13 x i8] c" pushq $%d\0A\00"
@.str.13 = [18 x i8] c" .quad vector%d\0A\00"
@str = [10 x i8] c"# handler\00"
@str.14 = [6 x i8] c".text\00"
@str.15 = [18 x i8] c".globl __alltraps\00"
@str.16 = [15 x i8] c"# vector table\00"
@str.17 = [6 x i8] c".data\00"
@str.18 = [17 x i8] c".globl __vectors\00"
@str.19 = [11 x i8] c"__vectors:\00"
@str.20 = [17 x i8] c" jmp __alltraps\00"
@str.21 = [11 x i8] c" pushq $0\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.14, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.15, i64 0, i64 0))
br label %4
4: ; preds = %0, %10
%5 = phi i32 [ 0, %0 ], [ %13, %10 ]
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %5)
switch i32 %5, label %8 [
i32 17, label %10
i32 14, label %10
i32 13, label %10
i32 12, label %10
i32 11, label %10
i32 10, label %10
i32 9, label %10
i32 8, label %10
]
8: ; preds = %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.21, i64 0, i64 0))
br label %10
10: ; preds = %4, %4, %4, %4, %4, %4, %4, %4, %8
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %5)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.20, i64 0, i64 0))
%13 = add nuw nsw i32 %5, 1
%14 = icmp eq i32 %13, 256
br i1 %14, label %15, label %4
15: ; preds = %10
%16 = tail call i32 @putchar(i32 10)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.16, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.17, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.18, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.19, i64 0, i64 0))
br label %21
21: ; preds = %15, %21
%22 = phi i32 [ 0, %15 ], [ %24, %21 ]
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i32 %22, 1
%25 = icmp eq i32 %24, 256
br i1 %25, label %26, label %21
26: ; preds = %21
ret i32 0
}