#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*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ hash_insert(char *, char *);
int /*<<< orphan*/ printf(char *);
int build_dictionary(char *fname) {
  int i = 0;
  char key[100], data[200];
  FILE *ifp = fopen(fname, "r");
  if (ifp == NULL) {
    printf("No such file ! \n");
    exit(1);
  }
  while (fscanf(ifp, "%s %s", key, data) == 2) {
    hash_insert(key, data);
    i++;
  }
  fclose(ifp);
  return (i);
}


x86 assembly (clang, -O0):
<build_dictionary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x148(%rbp)
jne    11b1 <build_dictionary+0x51>
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11b6 <build_dictionary+0x56>
mov    -0x148(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    -0x140(%rbp),%rcx
lea    0xe44(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x2,%eax
jne    11fb <build_dictionary+0x9b>
lea    -0x70(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1030 <hash_insert@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b6 <build_dictionary+0x56>
mov    -0x148(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xc(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_dictionary>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x140,%rsp
lea    0xe8a(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11fe <build_dictionary+0x9e>
mov    %rax,%r14
lea    0xe78(%rip),%rsi
mov    %rsp,%rdx
lea    0x70(%rsp),%rcx
mov    %rax,%rdi
call   1060 <fscanf@plt>
xor    %ebp,%ebp
cmp    $0x2,%eax
jne    11e4 <build_dictionary+0x84>
xor    %ebp,%ebp
mov    %rsp,%r15
lea    0x70(%rsp),%rbx
lea    0xe50(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <hash_insert@plt>
add    $0x1,%ebp
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1060 <fscanf@plt>
cmp    $0x2,%eax
je     11c0 <build_dictionary+0x60>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x140,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"No such file ! \0A\00"
@.str.2 = [6 x i8] c"%s %s\00"
define i32 @build_dictionary(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca [200 x i8]
%6 = alloca i32*
store i8* %0, i8** %2
store i32 0, i32* %3
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %1
br label %15
15: ; preds = %21, %14
%16 = load i32*, i32** %6
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%18 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%19 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %17, i8* %18)
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %27
21: ; preds = %15
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%24 = call i32 @hash_insert(i8* %22, i8* %23)
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %15
27: ; preds = %15
%28 = load i32*, i32** %6
%29 = call i32 @fclose(i32* %28)
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%s %s\00"
@str = [16 x i8] c"No such file ! \00"
define i32 @build_dictionary(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %5)
%10 = icmp eq i32 %9, 2
br i1 %10, label %14, label %20
11: ; preds = %1
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8, %14
%15 = phi i32 [ %17, %14 ], [ 0, %8 ]
%16 = call i32 @hash_insert(i8* %4, i8* %5)
%17 = add nuw nsw i32 %15, 1
%18 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %5)
%19 = icmp eq i32 %18, 2
br i1 %19, label %14, label %20
20: ; preds = %14, %8
%21 = phi i32 [ 0, %8 ], [ %17, %14 ]
%22 = call i32 @fclose(i32* %6)
ret i32 %21
}