#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 uint16_t;

/* Variables and functions */
scalar_t__ PiToCallsign(int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  uint16_t picode;
  char callsign[5];
  printf("Enter a 16-bit hexadecimal pi code: ");
  scanf("%x", &picode);
  printf("Converting code %X\n", picode);
  if (PiToCallsign(picode, callsign) == 0) {
    printf("Callsign is %s\n", callsign);
  } else {
    printf("Invalid PI code entered");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0xd(%rbp),%rsi
call   1050 <PiToCallsign@plt>
cmp    $0x0,%rax
jne    119b <main+0x6b>
lea    -0xd(%rbp),%rsi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a9 <main+0x79>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edi
lea    0x13(%rsp),%rsi
call   1050 <PiToCallsign@plt>
test   %rax,%rax
je     1188 <main+0x58>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    119b <main+0x6b>
lea    0xead(%rip),%rdi
lea    0x13(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Enter a 16-bit hexadecimal pi code: \00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [20 x i8] c"Converting code %X\0A\00"
@.str.3 = [16 x i8] c"Callsign is %s\0A\00"
@.str.4 = [24 x i8] c"Invalid PI code entered\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%10 = call i64 @PiToCallsign(i32 %8, i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %13)
br label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Enter a 16-bit hexadecimal pi code: \00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [20 x i8] c"Converting code %X\0A\00"
@.str.3 = [16 x i8] c"Callsign is %s\0A\00"
@.str.4 = [24 x i8] c"Invalid PI code entered\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %1
%10 = call i64 @PiToCallsign(i32 %9, i8* %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
ret i32 0
}