#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *find(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
main() {
  FILE *fp;
  char ssn[10];
  printf("Please enter the SSN of the employee to be fired.\n");
  scanf("%s", ssn);
  fp = find(ssn);
  if (fp == 0) {
    printf("Employee does not exist.\n");
    scanf("%s", ssn);
    exit(1);
  }
  fprintf(fp, "%3d", 1);
  fclose(fp);
  printf("Firing complete.\n");
  scanf("%s", ssn);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    -0x12(%rbp),%rsi
lea    0xeb4(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x12(%rbp),%rdi
call   1060 <find@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11c2 <main+0x62>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
lea    -0x12(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1070 <scanf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x1,%edx
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x12(%rbp),%rsi
lea    0xe3c(%rip),%rdi
call   1070 <scanf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe88(%rip),%rdi
lea    0x6(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
call   1060 <find@plt>
test   %rax,%rax
je     11d6 <main+0x76>
mov    %rax,%rbx
lea    0xe67(%rip),%rsi
mov    %rax,%rdi
mov    $0x1,%edx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3c(%rip),%rdi
lea    0x6(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe17(%rip),%rdi
lea    0x6(%rsp),%rsi
call   1070 <scanf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"Please enter the SSN of the employee to be fired.\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"Employee does not exist.\0A\00"
@.str.3 = [4 x i8] c"%3d\00"
@.str.4 = [18 x i8] c"Firing complete.\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca [10 x i8]
%3 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = call i32* @find(i8* %6)
store i32* %7, i32** %1
%8 = load i32*, i32** %1
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = load i32*, i32** %1
%17 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 1)
%18 = load i32*, i32** %1
%19 = call i32 @fclose(i32* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c"%3d\00"
@str = [50 x i8] c"Please enter the SSN of the employee to be fired.\00"
@str.5 = [17 x i8] c"Firing complete.\00"
@str.6 = [25 x i8] c"Employee does not exist.\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32* @find(i8* %2)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 1)
%13 = call i32 @fclose(i32* %5)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}