#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*/ sprintf(char *, char *, unsigned char);
char *restart_code(unsigned char code) {
  static char buffer[25];
  if (code == 0x00 || (code & 0x80) == 0x80)
    return "DTE Originated";
  if (code == 0x01)
    return "Local Procedure Error";
  if (code == 0x03)
    return "Network Congestion";
  if (code == 0x07)
    return "Network Operational";
  sprintf(buffer, "Unknown %02X", code);
  return buffer;
}


x86 assembly (clang, -O0):
<restart_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x0,%eax
je     113f <restart_code+0x2f>
movzbl -0x9(%rbp),%eax
and    $0x80,%eax
cmp    $0x80,%eax
jne    114f <restart_code+0x3f>
lea    0xeba(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c8 <restart_code+0xb8>
movzbl -0x9(%rbp),%eax
cmp    $0x1,%eax
jne    116c <restart_code+0x5c>
lea    0xeac(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c8 <restart_code+0xb8>
movzbl -0x9(%rbp),%eax
cmp    $0x3,%eax
jne    1189 <restart_code+0x79>
lea    0xea5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c8 <restart_code+0xb8>
movzbl -0x9(%rbp),%eax
cmp    $0x7,%eax
jne    11a6 <restart_code+0x96>
lea    0xe9b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c8 <restart_code+0xb8>
lea    0x2e93(%rip),%rdi
lea    0xe98(%rip),%rsi
movzbl -0x9(%rbp),%edx
call   1030 <sprintf@plt>
lea    0x2e7c(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<restart_code>:
push   %rbx
test   %dil,%dil
jle    1131 <restart_code+0x21>
cmp    $0x1,%dil
je     113a <restart_code+0x2a>
cmp    $0x7,%dil
je     1143 <restart_code+0x33>
cmp    $0x3,%dil
jne    114c <restart_code+0x3c>
lea    0xef6(%rip),%rbx
jmp    1166 <restart_code+0x56>
lea    0xec8(%rip),%rbx
jmp    1166 <restart_code+0x56>
lea    0xece(%rip),%rbx
jmp    1166 <restart_code+0x56>
lea    0xeee(%rip),%rbx
jmp    1166 <restart_code+0x56>
movzbl %dil,%edx
lea    0x2ee9(%rip),%rbx
lea    0xeee(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@restart_code.buffer = internal global [25 x i8] zeroinitializer
@.str = [15 x i8] c"DTE Originated\00"
@.str.1 = [22 x i8] c"Local Procedure Error\00"
@.str.2 = [19 x i8] c"Network Congestion\00"
@.str.3 = [20 x i8] c"Network Operational\00"
@.str.4 = [13 x i8] c"Unknown %02X\00"
define i8* @restart_code(i8 zeroext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = icmp eq i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = load i8, i8* %3
%9 = zext i8 %8 to i32
%10 = and i32 %9, 128
%11 = icmp eq i32 %10, 128
br i1 %11, label %12, label %13
12: ; preds = %7, %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %2
br label %31
13: ; preds = %7
%14 = load i8, i8* %3
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %31
18: ; preds = %13
%19 = load i8, i8* %3
%20 = zext i8 %19 to i32
%21 = icmp eq i32 %20, 3
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %31
23: ; preds = %18
%24 = load i8, i8* %3
%25 = zext i8 %24 to i32
%26 = icmp eq i32 %25, 7
br i1 %26, label %27, label %28
27: ; preds = %23
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %31
28: ; preds = %23
%29 = load i8, i8* %3
%30 = call i32 @sprintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @restart_code.buffer, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %29)
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @restart_code.buffer, i64 0, i64 0), i8** %2
br label %31
31: ; preds = %28, %27, %22, %17, %12
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
@restart_code.buffer = internal global [25 x i8] zeroinitializer
@.str = [15 x i8] c"DTE Originated\00"
@.str.1 = [22 x i8] c"Local Procedure Error\00"
@.str.2 = [19 x i8] c"Network Congestion\00"
@.str.3 = [20 x i8] c"Network Operational\00"
@.str.4 = [13 x i8] c"Unknown %02X\00"
define i8* @restart_code(i8 zeroext %0) {
%2 = icmp sgt i8 %0, 0
br i1 %2, label %3, label %8
3: ; preds = %1
switch i8 %0, label %6 [
i8 1, label %8
i8 3, label %4
i8 7, label %5
]
4: ; preds = %3
br label %8
5: ; preds = %3
br label %8
6: ; preds = %3
%7 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @restart_code.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %0)
br label %8
8: ; preds = %3, %1, %6, %5, %4
%9 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @restart_code.buffer, i64 0, i64 0), %6 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %3 ]
ret i8* %9
}