#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 */
struct addrinfo {
  int ai_protocol;
};

/* Variables and functions */
#define IPPROTO_RAW 130
#define IPPROTO_TCP 129
#define IPPROTO_UDP 128
int /*<<< orphan*/ printf(char *);
void print_protocal(struct addrinfo *aip) {
  if (aip == (struct addrinfo *)0)
    return;
  printf("protocal ");
  switch (aip->ai_protocol) {
  case 0:
    printf("default ");
    break;
  case IPPROTO_TCP:
    printf("tcp ");
    break;
  case IPPROTO_UDP:
    printf("udp ");
    break;
  case IPPROTO_RAW:
    printf("raw ");
    break;
  default:
    printf("unknown ");
    break;
  }
}


x86 assembly (clang, -O0):
<print_protocal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112c <print_protocal+0x1c>
jmp    11d7 <print_protocal+0xc7>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     1187 <print_protocal+0x77>
jmp    114e <print_protocal+0x3e>
mov    -0xc(%rbp),%eax
sub    $0x80,%eax
je     11a9 <print_protocal+0x99>
jmp    1161 <print_protocal+0x51>
mov    -0xc(%rbp),%eax
sub    $0x81,%eax
je     1198 <print_protocal+0x88>
jmp    1174 <print_protocal+0x64>
mov    -0xc(%rbp),%eax
sub    $0x82,%eax
je     11ba <print_protocal+0xaa>
jmp    11cb <print_protocal+0xbb>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    11d7 <print_protocal+0xc7>
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
jmp    11d7 <print_protocal+0xc7>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
jmp    11d7 <print_protocal+0xc7>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    11d7 <print_protocal+0xc7>
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_protocal>:
test   %rdi,%rdi
je     1146 <print_protocal+0x36>
push   %rbx
mov    %rdi,%rbx
lea    0xee0(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
cmp    $0x80,%eax
pop    %rbx
jg     1147 <print_protocal+0x37>
test   %eax,%eax
je     116d <print_protocal+0x5d>
cmp    $0x80,%eax
jne    1161 <print_protocal+0x51>
lea    0xed7(%rip),%rdi
jmp    1030 <printf@plt>
ret
cmp    $0x82,%eax
je     1179 <print_protocal+0x69>
cmp    $0x81,%eax
jne    1161 <print_protocal+0x51>
lea    0xeb7(%rip),%rdi
jmp    1030 <printf@plt>
lea    0xeba(%rip),%rdi
jmp    1030 <printf@plt>
lea    0xe96(%rip),%rdi
jmp    1030 <printf@plt>
lea    0xe9d(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32 }
@.str = [10 x i8] c"protocal \00"
@.str.1 = [9 x i8] c"default \00"
@.str.2 = [5 x i8] c"tcp \00"
@.str.3 = [5 x i8] c"udp \00"
@.str.4 = [5 x i8] c"raw \00"
@.str.5 = [9 x i8] c"unknown \00"
define void @print_protocal(%struct.addrinfo* %0) {
%2 = alloca %struct.addrinfo*
store %struct.addrinfo* %0, %struct.addrinfo** %2
%3 = load %struct.addrinfo*, %struct.addrinfo** %2
%4 = icmp eq %struct.addrinfo* %3, null
br i1 %4, label %5, label %6
5: ; preds = %1
br label %21
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = load %struct.addrinfo*, %struct.addrinfo** %2
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 0
%10 = load i32, i32* %9
switch i32 %10, label %19 [
i32 0, label %11
i32 129, label %13
i32 128, label %15
i32 130, label %17
]
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %21
13: ; preds = %6
%14 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %21
15: ; preds = %6
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %21
17: ; preds = %6
%18 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %21
19: ; preds = %6
%20 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %21
21: ; preds = %5, %19, %17, %15, %13, %11
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@.str = [10 x i8] c"protocal \00"
@.str.1 = [9 x i8] c"default \00"
@.str.2 = [5 x i8] c"tcp \00"
@.str.3 = [5 x i8] c"udp \00"
@.str.4 = [5 x i8] c"raw \00"
@.str.5 = [9 x i8] c"unknown \00"
define void @print_protocal(%struct.addrinfo* %0) {
%2 = icmp eq %struct.addrinfo* %0, null
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %0, i64 0, i32 0
%6 = load i32, i32* %5
switch i32 %6, label %10 [
i32 0, label %11
i32 129, label %7
i32 128, label %8
i32 130, label %9
]
7: ; preds = %3
br label %11
8: ; preds = %3
br label %11
9: ; preds = %3
br label %11
10: ; preds = %3
br label %11
11: ; preds = %3, %7, %8, %9, %10
%12 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %3 ]
%13 = tail call i32 @printf(i8* dereferenceable(1) %12)
br label %14
14: ; preds = %11, %1
ret void
}