#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 < 10 || i > 14) && i != 17) {
      printf("  pushl $0\n");
    }
    printf("  pushl $%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("  .long 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    11e2 <main+0xd2>
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)
je     11b5 <main+0xa5>
cmpl   $0xa,-0x8(%rbp)
jl     119d <main+0x8d>
cmpl   $0xe,-0x8(%rbp)
jle    11b5 <main+0xa5>
cmpl   $0x11,-0x8(%rbp)
je     11b5 <main+0xa5>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%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    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    125b <main+0x14b>
mov    -0x8(%rbp),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    122f <main+0x11f>
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),%r12
lea    0xea8(%rip),%r13
lea    0xf13(%rip),%rbx
mov    $0x27d00,%r15d
xor    %ebp,%ebp
jmp    11bf <main+0x8f>
lea    0xf13(%rip),%rdi
call   1040 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%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     11e4 <main+0xb4>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x11,%ebp
ja     1185 <main+0x55>
bt     %ebp,%r15d
jb     11a0 <main+0x70>
jmp    1185 <main+0x55>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe65(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe04(%rip),%rbx
xor    %ebp,%ebp
nopw   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" pushl $0\0A\00"
@.str.6 = [13 x i8] c" pushl $%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" .long 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 = %31, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 256
br i1 %8, label %9, label %34
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 ne i32 %14, 8
br i1 %15, label %16, label %27
16: ; preds = %9
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 10
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = icmp sgt i32 %20, 14
br i1 %21, label %22, label %27
22: ; preds = %19, %16
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 17
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %22, %19, %9
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %31
31: ; preds = %27
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %6
34: ; preds = %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%39 = 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 %40
40: ; preds = %46, %34
%41 = load i32, i32* %2
%42 = icmp slt i32 %41, 256
br i1 %42, label %43, label %49
43: ; preds = %40
%44 = load i32, i32* %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %43
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %40
49: ; preds = %40
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" pushl $%d\0A\00"
@.str.13 = [18 x i8] c" .long 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" pushl $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 8, label %10
i32 17, label %10
i32 14, label %10
i32 13, label %10
i32 12, label %10
i32 11, label %10
i32 10, 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, %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
}