#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void print_args(int nargs, uint8_t *arg) {
  int i;
  for (i = 0; i < nargs; i++) {
    if (i)
      printf(", ");
    switch (arg[i]) {
    case 8:
      printf("byte");
      break;
    case 16:
      printf("int16");
      break;
    case 32:
      printf("int");
      break;
    case 37:
      printf("byte[]");
      break;
    case 38:
      printf("int[]");
      break;
    case 39:
      printf("asciiz");
      break;
    case 41:
      printf("f100");
      break;
    case 42:
      printf("fixed");
      break;
    case 43:
      printf("bool");
      break;
    case 44:
      printf("fixed[]");
      break;
    default:
      printf("unknown");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<print_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1242 <print_args+0x132>
cmpl   $0x0,-0x14(%rbp)
je     1148 <print_args+0x38>
lea    0xf51(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x24,%eax
ja     1223 <print_args+0x113>
mov    -0x20(%rbp),%rax
lea    0xe90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf17(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xf0b(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xf00(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xef3(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xed4(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_args+0x11f>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    1234 <print_args+0x124>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <print_args+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11ab <print_args+0x9b>
mov    %rsi,%r15
mov    %edi,%ebp
mov    (%rsi),%eax
add    $0xfffffff8,%eax
cmp    $0x24,%eax
ja     1152 <print_args+0x42>
lea    0x1025(%rip),%rdi
lea    0xec0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xfdb(%rip),%rdi
jmp    11a1 <print_args+0x91>
lea    0x100d(%rip),%rdi
jmp    11a1 <print_args+0x91>
lea    0xfce(%rip),%rdi
jmp    11a1 <print_args+0x91>
lea    0xfcb(%rip),%rdi
jmp    11a1 <print_args+0x91>
lea    0xfc6(%rip),%rdi
jmp    11a1 <print_args+0x91>
lea    0xfc4(%rip),%rdi
jmp    11a1 <print_args+0x91>
lea    0xfc1(%rip),%rdi
jmp    11a1 <print_args+0x91>
lea    0xfbf(%rip),%rdi
jmp    11a1 <print_args+0x91>
lea    0xfbb(%rip),%rdi
jmp    11a1 <print_args+0x91>
lea    0xfb8(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x1,%ebp
jne    11ba <print_args+0xaa>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%ebp
mov    $0x1,%ebx
lea    0xf60(%rip),%r14
lea    0xf5c(%rip),%r12
lea    0xebe(%rip),%r13
jmp    11ee <print_args+0xde>
lea    0xf87(%rip),%rdi
nop
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11ab <print_args+0x9b>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r15,%rbx,4),%eax
add    $0xfffffff8,%eax
cmp    $0x24,%eax
ja     11d8 <print_args+0xc8>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
mov    %r12,%rdi
jmp    *%rax
lea    0xf1a(%rip),%rdi
jmp    11e0 <print_args+0xd0>
lea    0xf17(%rip),%rdi
jmp    11e0 <print_args+0xd0>
lea    0xf12(%rip),%rdi
jmp    11e0 <print_args+0xd0>
lea    0xf10(%rip),%rdi
jmp    11e0 <print_args+0xd0>
lea    0xf0d(%rip),%rdi
jmp    11e0 <print_args+0xd0>
lea    0xf0b(%rip),%rdi
jmp    11e0 <print_args+0xd0>
lea    0xf07(%rip),%rdi
jmp    11e0 <print_args+0xd0>
lea    0xf09(%rip),%rdi
jmp    11e0 <print_args+0xd0>
lea    0xefb(%rip),%rdi
jmp    11e0 <print_args+0xd0>

LLVM IR (-O0):
@.str = [3 x i8] c", \00"
@.str.1 = [5 x i8] c"byte\00"
@.str.2 = [6 x i8] c"int16\00"
@.str.3 = [4 x i8] c"int\00"
@.str.4 = [7 x i8] c"byte[]\00"
@.str.5 = [6 x i8] c"int[]\00"
@.str.6 = [7 x i8] c"asciiz\00"
@.str.7 = [5 x i8] c"f100\00"
@.str.8 = [6 x i8] c"fixed\00"
@.str.9 = [5 x i8] c"bool\00"
@.str.10 = [8 x i8] c"fixed[]\00"
@.str.11 = [8 x i8] c"unknown\00"
define void @print_args(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %6
6: ; preds = %44, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %47
10: ; preds = %6
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = load i32*, i32** %4
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
switch i32 %20, label %41 [
i32 8, label %21
i32 16, label %23
i32 32, label %25
i32 37, label %27
i32 38, label %29
i32 39, label %31
i32 41, label %33
i32 42, label %35
i32 43, label %37
i32 44, label %39
]
21: ; preds = %15
%22 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %43
23: ; preds = %15
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %43
25: ; preds = %15
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %43
27: ; preds = %15
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %43
29: ; preds = %15
%30 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %43
31: ; preds = %15
%32 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %43
33: ; preds = %15
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %43
35: ; preds = %15
%36 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %43
37: ; preds = %15
%38 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %43
39: ; preds = %15
%40 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %43
41: ; preds = %15
%42 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
br label %43
43: ; preds = %41, %39, %37, %35, %33, %31, %29, %27, %25, %23, %21
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %6
47: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c", \00"
@.str.1 = [5 x i8] c"byte\00"
@.str.2 = [6 x i8] c"int16\00"
@.str.3 = [4 x i8] c"int\00"
@.str.4 = [7 x i8] c"byte[]\00"
@.str.5 = [6 x i8] c"int[]\00"
@.str.6 = [7 x i8] c"asciiz\00"
@.str.7 = [5 x i8] c"f100\00"
@.str.8 = [6 x i8] c"fixed\00"
@.str.9 = [5 x i8] c"bool\00"
@.str.10 = [8 x i8] c"fixed[]\00"
@.str.11 = [8 x i8] c"unknown\00"
define void @print_args(i32 %0, i32* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %41
4: ; preds = %2
%5 = zext i32 %0 to i64
%6 = load i32, i32* %1
switch i32 %6, label %16 [
i32 8, label %15
i32 16, label %14
i32 32, label %13
i32 37, label %12
i32 38, label %11
i32 39, label %10
i32 41, label %9
i32 42, label %8
i32 43, label %7
i32 44, label %17
]
7: ; preds = %4
br label %17
8: ; preds = %4
br label %17
9: ; preds = %4
br label %17
10: ; preds = %4
br label %17
11: ; preds = %4
br label %17
12: ; preds = %4
br label %17
13: ; preds = %4
br label %17
14: ; preds = %4
br label %17
15: ; preds = %4
br label %17
16: ; preds = %4
br label %17
17: ; preds = %4, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7
%18 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), %16 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %15 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %14 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %13 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %12 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %11 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), %4 ]
%19 = tail call i32 @printf(i8* dereferenceable(1) %18)
%20 = icmp eq i32 %0, 1
br i1 %20, label %41, label %21
21: ; preds = %17, %36
%22 = phi i64 [ %39, %36 ], [ 1, %17 ]
%23 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%24 = getelementptr inbounds i32, i32* %1, i64 %22
%25 = load i32, i32* %24
switch i32 %25, label %35 [
i32 8, label %36
i32 16, label %26
i32 32, label %27
i32 37, label %28
i32 38, label %29
i32 39, label %30
i32 41, label %31
i32 42, label %32
i32 43, label %33
i32 44, label %34
]
26: ; preds = %21
br label %36
27: ; preds = %21
br label %36
28: ; preds = %21
br label %36
29: ; preds = %21
br label %36
30: ; preds = %21
br label %36
31: ; preds = %21
br label %36
32: ; preds = %21
br label %36
33: ; preds = %21
br label %36
34: ; preds = %21
br label %36
35: ; preds = %21
br label %36
36: ; preds = %21, %26, %27, %28, %29, %30, %31, %32, %33, %34, %35
%37 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %26 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %27 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %28 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %29 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), %30 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %31 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), %32 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), %33 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), %34 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), %35 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %21 ]
%38 = tail call i32 @printf(i8* dereferenceable(1) %37)
%39 = add nuw nsw i64 %22, 1
%40 = icmp eq i64 %39, %5
br i1 %40, label %41, label %21
41: ; preds = %36, %17, %2
ret void
}