#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_protocol(struct addrinfo *aip) {
  printf("  protocol ");
  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 (%d)", aip->ai_protocol);
    break;
  }
}


x86 assembly (clang, -O0):
<print_protocol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     1179 <print_protocol+0x69>
jmp    1140 <print_protocol+0x30>
mov    -0xc(%rbp),%eax
sub    $0x80,%eax
je     119f <print_protocol+0x8f>
jmp    1153 <print_protocol+0x43>
mov    -0xc(%rbp),%eax
sub    $0x81,%eax
je     118c <print_protocol+0x7c>
jmp    1166 <print_protocol+0x56>
mov    -0xc(%rbp),%eax
sub    $0x82,%eax
je     11b2 <print_protocol+0xa2>
jmp    11c5 <print_protocol+0xb5>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <print_protocol+0xc9>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <print_protocol+0xc9>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <print_protocol+0xc9>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <print_protocol+0xc9>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_protocol>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%esi
cmp    $0x80,%esi
jg     1141 <print_protocol+0x31>
test   %esi,%esi
je     1169 <print_protocol+0x59>
cmp    $0x80,%esi
jne    115a <print_protocol+0x4a>
lea    0xed9(%rip),%rdi
jmp    1179 <print_protocol+0x69>
cmp    $0x81,%esi
je     1172 <print_protocol+0x62>
cmp    $0x82,%esi
jne    115a <print_protocol+0x4a>
lea    0xec4(%rip),%rdi
jmp    1179 <print_protocol+0x69>
lea    0xebf(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>
lea    0xe9c(%rip),%rdi
jmp    1179 <print_protocol+0x69>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

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

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