#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 /*<<< orphan*/ fxor(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                        int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **args) {
  FILE *fp1, *fp2, *fp_out;
  if (argc != 4) {
    printf("%i Parameter erwartet %i erhalten.\n", 4 - 1, argc - 1);
    return 2;
  }
  fp1 = fopen(args[1], "r");
  fp2 = fopen(args[2], "r");
  fp_out = fopen(args[3], "w");
  if (fp1 == NULL || fp2 == NULL || fp_out == NULL) {
    printf("Konnte eine oder beide Dateien nicht öffnen\n");
    return 1;
  }
  fxor(fp1, fp2, fp_out);
  fclose(fp1);
  fclose(fp2);
  fclose(fp_out);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1185 <main+0x45>
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
lea    0xe93(%rip),%rdi
mov    $0x3,%esi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1234 <main+0xf4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe90(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe78(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe62(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ee <main+0xae>
cmpq   $0x0,-0x20(%rbp)
je     11ee <main+0xae>
cmpq   $0x0,-0x28(%rbp)
jne    1208 <main+0xc8>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1234 <main+0xf4>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <fxor@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x4,%edi
jne    11ce <main+0x7e>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xebc(%rip),%r15
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    0x18(%rbx),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
test   %r14,%r14
je     11ed <main+0x9d>
test   %r15,%r15
je     11ed <main+0x9d>
mov    %rax,%rbx
test   %rax,%rax
je     11ed <main+0x9d>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fxor@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    11fe <main+0xae>
mov    %edi,%edx
add    $0xffffffff,%edx
lea    0xe26(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x2,%eax
jmp    11fe <main+0xae>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"%i Parameter erwartet %i erhalten.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [46 x i8] c"Konnte eine oder beide Dateien nicht \C3\B6ffnen\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 4
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 3, i32 %13)
store i32 2, i32* %3
br label %49
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %27, i32** %8
%28 = load i32*, i32** %6
%29 = icmp eq i32* %28, null
br i1 %29, label %36, label %30
30: ; preds = %15
%31 = load i32*, i32** %7
%32 = icmp eq i32* %31, null
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32*, i32** %8
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %38
36: ; preds = %33, %30, %15
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %49
38: ; preds = %33
%39 = load i32*, i32** %6
%40 = load i32*, i32** %7
%41 = load i32*, i32** %8
%42 = call i32 @fxor(i32* %39, i32* %40, i32* %41)
%43 = load i32*, i32** %6
%44 = call i32 @fclose(i32* %43)
%45 = load i32*, i32** %7
%46 = call i32 @fclose(i32* %45)
%47 = load i32*, i32** %8
%48 = call i32 @fclose(i32* %47)
br label %49
49: ; preds = %38, %36, %11
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [36 x i8] c"%i Parameter erwartet %i erhalten.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@str = [45 x i8] c"Konnte eine oder beide Dateien nicht \C3\B6ffnen\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = add nsw i32 %0, -1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 3, i32 %5)
br label %29
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32* %10, null
%18 = icmp eq i32* %13, null
%19 = or i1 %17, %18
%20 = icmp eq i32* %16, null
%21 = or i1 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %7
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %29
24: ; preds = %7
%25 = tail call i32 @fxor(i32* %10, i32* %13, i32* %16)
%26 = tail call i32 @fclose(i32* %10)
%27 = tail call i32 @fclose(i32* %13)
%28 = tail call i32 @fclose(i32* %16)
br label %29
29: ; preds = %24, %22, %4
%30 = phi i32 [ 2, %4 ], [ 1, %22 ], [ 0, %24 ]
ret i32 %30
}