#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*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
void openFile(FILE **fin, char *fileName) {
  if (strlen(fileName) > 1000) {
    printf("The length of file name is too long\n");
    exit(1);
  }
  if (!(*fin = fopen(fileName, "r"))) {
    printf("No file!\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<openFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3e8,%eax
jle    117a <openFile+0x3a>
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1050 <fopen@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11b1 <openFile+0x71>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openFile>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
cmp    $0x3e9,%eax
jge    1178 <openFile+0x38>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     1181 <openFile+0x41>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe8c(%rip),%rdi
jmp    1188 <openFile+0x48>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"The length of file name is too long\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"No file!\0A\00"
define void @openFile(i32** %0, i8* %1) {
%3 = alloca i32**
%4 = alloca i8*
store i32** %0, i32*** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i32 @strlen(i8* %5)
%7 = icmp sgt i32 %6, 1000
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32**, i32*** %3
store i32* %13, i32** %14
%15 = icmp ne i32* %13, null
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@str = [9 x i8] c"No file!\00"
@str.3 = [36 x i8] c"The length of file name is too long\00"
define void @openFile(i32** nocapture writeonly %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = icmp sgt i32 %3, 1000
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.3, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %0
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8
ret void
}