#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*/ fscanf(int /*<<< orphan*/ *, char *, int *, char *, char *,
                          float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
main() {
  FILE *fp;
  char rssn[10];
  int del;
  char ssn[10], name[21];
  float sal;
  printf("Please enter SSN\n");
  scanf("%s", rssn);
  fp = find(rssn);
  if (fp == 0) {
    printf("SSN not found\n");
    scanf("%s", ssn);
    exit(1);
  }
  fscanf(fp, "%d%s%s%f", &del, ssn, name, &sal);
  printf("ssn = %s name = %s salary = %10.2f\n", ssn, name, sal);
  fclose(fp);
  printf("retrieve complete\n");
  scanf("%s", ssn);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x12(%rbp),%rdi
call   1060 <find@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11c6 <main+0x66>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x22(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1070 <scanf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    -0x22(%rbp),%rcx
lea    -0x40(%rbp),%r8
lea    0xe4b(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x44(%rbp),%r9
call   1050 <fscanf@plt>
lea    -0x22(%rbp),%rsi
lea    -0x40(%rbp),%rdx
movss  -0x44(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x22(%rbp),%rsi
lea    0xdeb(%rip),%rdi
call   1070 <scanf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe74(%rip),%rdi
lea    0x16(%rsp),%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1070 <find@plt>
test   %rax,%rax
je     121f <main+0xaf>
mov    %rax,%rbx
lea    0xe53(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%r14
lea    0x20(%rsp),%r15
lea    0x4(%rsp),%r9
mov    %rax,%rdi
mov    %r14,%rcx
mov    %r15,%r8
call   1060 <fscanf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe29(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf5(%rip),%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xdce(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Please enter SSN\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [15 x i8] c"SSN not found\0A\00"
@.str.3 = [9 x i8] c"%d%s%s%f\00"
@.str.4 = [36 x i8] c"ssn = %s name = %s salary = %10.2f\0A\00"
@.str.5 = [19 x i8] c"retrieve complete\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca [21 x i8]
%6 = alloca float
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = call i32* @find(i8* %10)
store i32* %11, i32** %1
%12 = load i32*, i32** %1
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %0
%20 = load i32*, i32** %1
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%22 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%23 = call i32 @fscanf(i32* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %3, i8* %21, i8* %22, float* %6)
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%25 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %24, i8* %25, double %27)
%29 = load i32*, i32** %1
%30 = call i32 @fclose(i32* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %32)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [9 x i8] c"%d%s%s%f\00"
@.str.4 = [36 x i8] c"ssn = %s name = %s salary = %10.2f\0A\00"
@str = [17 x i8] c"Please enter SSN\00"
@str.6 = [18 x i8] c"retrieve complete\00"
@str.7 = [14 x i8] c"SSN not found\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = alloca [21 x i8]
%5 = alloca float
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%7 = bitcast i32* %2 to i8*
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%10 = bitcast float* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%13 = call i32* @find(i8* %6)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %0
%20 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %2, i8* %8, i8* %9, float* %5)
%21 = load float, float* %5
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* %9, double %22)
%24 = call i32 @fclose(i32* %13)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
ret i32 0
}