#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 */
char EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
void ldap_name_aus_Datei_auslesen(char *ldap_name) {
  int i;
  char c;
  FILE *ldap_name_datei = fopen("ldap_name", "r");
  if (ldap_name_datei) {
    for (i = 0; (c = getc(ldap_name_datei)) != EOF; i++) {
      ldap_name[i] = c;
    }
  } else {
    printf("Error opening file!\n");
    exit(1);
  }
  fclose(ldap_name_datei);
}


x86 assembly (clang, -O0):
<ldap_name_aus_Datei_auslesen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c7 <ldap_name_aus_Datei_auslesen+0x77>
movl   $0x0,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%eax
mov    0x2e4d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11c2 <ldap_name_aus_Datei_auslesen+0x72>
mov    -0xd(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1185 <ldap_name_aus_Datei_auslesen+0x35>
jmp    11dd <ldap_name_aus_Datei_auslesen+0x8d>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ldap_name_aus_Datei_auslesen>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xea1(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11b0 <ldap_name_aus_Datei_auslesen+0x60>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <getc@plt>
mov    0x2e66(%rip),%r15
cmp    (%r15),%al
je     11a3 <ldap_name_aus_Datei_auslesen+0x53>
nopw   0x0(%rax,%rax,1)
mov    %al,(%rbx)
mov    %r14,%rdi
call   1070 <getc@plt>
add    $0x1,%rbx
cmp    (%r15),%al
jne    1190 <ldap_name_aus_Datei_auslesen+0x40>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"ldap_name\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [21 x i8] c"Error opening file!\0A\00"
define void @ldap_name_aus_Datei_auslesen(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32*
store i8* %0, i8** %2
%6 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
%7 = load i32*, i32** %5
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %27
9: ; preds = %1
store i32 0, i32* %3
br label %10
10: ; preds = %23, %9
%11 = load i32*, i32** %5
%12 = call signext i8 @getc(i32* %11)
store i8 %12, i8* %4
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %13, %15
br i1 %16, label %17, label %26
17: ; preds = %10
%18 = load i8, i8* %4
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 %18, i8* %22
br label %23
23: ; preds = %17
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %10
26: ; preds = %10
br label %30
27: ; preds = %1
%28 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %26
%31 = load i32*, i32** %5
%32 = call i32 @fclose(i32* %31)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"ldap_name\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@str = [20 x i8] c"Error opening file!\00"
define void @ldap_name_aus_Datei_auslesen(i8* nocapture writeonly %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = tail call signext i8 @getc(i32* %2)
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %19, label %8
8: ; preds = %4, %8
%9 = phi i64 [ %12, %8 ], [ 0, %4 ]
%10 = phi i8 [ %13, %8 ], [ %5, %4 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 %10, i8* %11
%12 = add nuw i64 %9, 1
%13 = tail call signext i8 @getc(i32* %2)
%14 = load i8, i8* @EOF
%15 = icmp eq i8 %13, %14
br i1 %15, label %19, label %8
16: ; preds = %1
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %8, %4
%20 = tail call i32 @fclose(i32* %2)
ret void
}