#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ shuffle_lines(char, int /*<<< orphan*/ *,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  FILE *file1, *file2;
  char delimiter;
  if (argc != 4) {
    fprintf(stderr, "Usage: %s file1 file2 delimiter\n", argv[0]);
    exit(1);
  }
  if (!(file1 = fopen(argv[1], "r"))) {
    fprintf(stderr, "ERROR in %s: Cannot open %s\n", argv[0], argv[1]);
    exit(1);
  }
  if (!(file2 = fopen(argv[2], "r"))) {
    fprintf(stderr, "ERROR in %s: Cannot open %s\n", argv[0], argv[2]);
    exit(1);
  }
  delimiter = *argv[3];
  shuffle_lines(delimiter, file1, file2);
  fclose(file1);
  fclose(file2);
  return 0;
}


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     1198 <main+0x48>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ea <main+0x9a>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe28(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    123c <main+0xec>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xdf8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
movsbl %al,%edi
call   1040 <shuffle_lines@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x4,%edi
jne    11b7 <main+0x67>
mov    0x8(%r14),%rdi
lea    0xeb9(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11db <main+0x8b>
mov    %rax,%r15
mov    0x10(%r14),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ed <main+0x9d>
mov    %rax,%rbx
mov    0x18(%r14),%rax
movsbl (%rax),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <shuffle_lines@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe36(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
jmp    11fd <main+0xad>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x10(%r14),%rcx
lea    0xe1f(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Usage: %s file1 file2 delimiter\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"ERROR in %s: Cannot open %s\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 i8
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 %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = icmp ne i32* %22, null
br i1 %23, label %34, label %24
24: ; preds = %18
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %18
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %38, i32** %7
%39 = icmp ne i32* %38, null
br i1 %39, label %50, label %40
40: ; preds = %34
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 0
%44 = load i8*, i8** %43
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %44, i8* %47)
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %34
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
%54 = load i8, i8* %53
store i8 %54, i8* %8
%55 = load i8, i8* %8
%56 = load i32*, i32** %6
%57 = load i32*, i32** %7
%58 = call i32 @shuffle_lines(i8 signext %55, i32* %56, i32* %57)
%59 = load i32*, i32** %6
%60 = call i32 @fclose(i32* %59)
%61 = load i32*, i32** %7
%62 = call i32 @fclose(i32* %61)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Usage: %s file1 file2 delimiter\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"ERROR in %s: Cannot open %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = load i8*, i8** %10
%18 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* %17)
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %9
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %31
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %1
%28 = load i8*, i8** %21
%29 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %28)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %20
%32 = getelementptr inbounds i8*, i8** %1, i64 3
%33 = load i8*, i8** %32
%34 = load i8, i8* %33
%35 = tail call i32 @shuffle_lines(i8 signext %34, i32* %12, i32* %23)
%36 = tail call i32 @fclose(i32* %12)
%37 = tail call i32 @fclose(i32* %23)
ret i32 0
}