#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*/ *fopen(char *, char const *);
int /*<<< orphan*/ printf(char *, char *, char const *);
int /*<<< orphan*/ strncpy(char *, char *, int);
FILE *openFile(char *name, const char *restrict mode) {
  char dateiName[256];
  FILE *datei = NULL;
  if (name == NULL)
    return NULL;
  else
    strncpy(dateiName, name, 255 * sizeof(char));
  if ((datei = fopen(dateiName, mode)) == NULL) {
    printf("Fehler beim Oeffnen der Datei \"%s\" mit Modus \"%s\"!\n", name,
           mode);
  }
  return datei;
}


x86 assembly (clang, -O0):
<openFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x128(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1166 <openFile+0x36>
movq   $0x0,-0x8(%rbp)
jmp    11bb <openFile+0x8b>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xff,%edx
call   1030 <strncpy@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
jne    11b0 <openFile+0x80>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x128(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openFile>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
test   %rdi,%rdi
je     117c <openFile+0x4c>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xff,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
jne    117e <openFile+0x4e>
lea    0xe8f(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Fehler beim Oeffnen der Datei \22%s\22 mit Modus \22%s\22!\0A\00"
define i32* @openFile(i8* %0, i8* noalias %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* null, i32** %7
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
store i32* null, i32** %3
br label %26
11: ; preds = %2
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i32 @strncpy(i8* %12, i8* %13, i32 255)
br label %15
15: ; preds = %11
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %5
%18 = call i32* @fopen(i8* %16, i8* %17)
store i32* %18, i32** %7
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = load i8*, i8** %5
%23 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
br label %24
24: ; preds = %20, %15
%25 = load i32*, i32** %7
store i32* %25, i32** %3
br label %26
26: ; preds = %24, %10
%27 = load i32*, i32** %3
ret i32* %27
}

LLVM IR (-O2):
@.str = [52 x i8] c"Fehler beim Oeffnen der Datei \22%s\22 mit Modus \22%s\22!\0A\00"
define noalias i32* @openFile(i8* %0, i8* noalias %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %0, null
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = call i32 @strncpy(i8* %4, i8* %0, i32 255)
%8 = call i32* @fopen(i8* %4, i8* %1)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %12
12: ; preds = %6, %10, %2
%13 = phi i32* [ null, %2 ], [ null, %10 ], [ %8, %6 ]
ret i32* %13
}