#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getLine(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ produceWordlist(int /*<<< orphan*/ *, char *);
int main() {
  char phoneNumber[9];
  FILE *ofPtr;
  if ((ofPtr = fopen("genwordList.txt", "w")) == NULL) {
    printf("Error - unable to create file \"wordList.txt\"\n");
    return -1;
  }
  printf("Enter phone number: ");
  int numLen = getLine(phoneNumber, 9);
  if (numLen < 7) {
    printf("Error - Invalid phone number");
  } else {
    produceWordlist(ofPtr, phoneNumber);
  }
  fclose(ofPtr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1198 <main+0x48>
lea    0xe8b(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <main+0x9d>
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
lea    -0xd(%rbp),%rdi
mov    $0x9,%esi
call   1070 <getLine@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jge    11d0 <main+0x80>
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
jmp    11dd <main+0x8d>
mov    -0x18(%rbp),%rdi
lea    -0xd(%rbp),%rsi
call   1030 <produceWordlist@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11ae <main+0x4e>
mov    %rax,%rbx
lea    0xe8b(%rip),%rdi
call   1060 <printf@plt>
lea    0x7(%rsp),%rdi
mov    $0x9,%esi
call   1080 <getLine@plt>
cmp    $0x6,%eax
jg     11c1 <main+0x61>
lea    0xe80(%rip),%rdi
call   1060 <printf@plt>
jmp    11ce <main+0x6e>
lea    0xe8f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    11d8 <main+0x78>
lea    0x7(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <produceWordlist@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"genwordList.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [46 x i8] c"Error - unable to create file \22wordList.txt\22\0A\00"
@.str.3 = [21 x i8] c"Enter phone number: \00"
@.str.4 = [29 x i8] c"Error - Invalid phone number\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %24
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%12 = call i32 @getLine(i8* %11, i32 9)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 7
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %21
17: ; preds = %9
%18 = load i32*, i32** %3
%19 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%20 = call i32 @produceWordlist(i32* %18, i8* %19)
br label %21
21: ; preds = %17, %15
%22 = load i32*, i32** %3
%23 = call i32 @fclose(i32* %22)
store i32 0, i32* %1
br label %24
24: ; preds = %21, %7
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [16 x i8] c"genwordList.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [21 x i8] c"Enter phone number: \00"
@.str.4 = [29 x i8] c"Error - Invalid phone number\00"
@str = [45 x i8] c"Error - unable to create file \22wordList.txt\22\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %17
7: ; preds = %0
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @getLine(i8* %2, i32 9)
%10 = icmp slt i32 %9, 7
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %15
13: ; preds = %7
%14 = call i32 @produceWordlist(i32* %3, i8* %2)
br label %15
15: ; preds = %13, %11
%16 = call i32 @fclose(i32* %3)
br label %17
17: ; preds = %15, %5
%18 = phi i32 [ -1, %5 ], [ 0, %15 ]
ret i32 %18
}