#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
int main(int argc, char *argv[]) {
  FILE *f1, *f2, *f3;
  f1 = fopen(argv[1], "r");
  f2 = fopen(argv[2], "r");
  f3 = fopen("2-DATA.out", "w");
  int a, b;
  fscanf(f1, "%d", &a);
  fscanf(f2, "%d", &b);
  while (1) {
    if (a < b) {
      fprintf(f3, "%d ", a);
      if (fscanf(f1, "%d", &a) == EOF)
        break;
    } else {
      fprintf(f3, "%d ", b);
      if (fscanf(f2, "%d", &b) == EOF)
        break;
    }
  }
  while (1) {
    fprintf(f3, "%d ", a);
    if (fscanf(f1, "%d", &a) == EOF)
      break;
  }
  while (1) {
    fprintf(f3, "%d ", b);
    if (fscanf(f2, "%d", &b) == EOF)
      break;
  }
  fclose(f1);
  fclose(f2);
  fclose(f3);
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe83(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    0xe75(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe67(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe53(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1212 <main+0xd2>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xe33(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe20(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1040 <fscanf@plt>
mov    0x2de9(%rip),%rcx
cmp    (%rcx),%rax
jne    120d <main+0xcd>
jmp    1258 <main+0x118>
jmp    1253 <main+0x113>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%edx
lea    0xdf2(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xddf(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <fscanf@plt>
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%rax
jne    124e <main+0x10e>
jmp    1258 <main+0x118>
jmp    1253 <main+0x113>
jmp    11c5 <main+0x85>
jmp    125d <main+0x11d>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xda7(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd94(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1040 <fscanf@plt>
mov    0x2d5d(%rip),%rcx
cmp    (%rcx),%rax
jne    1299 <main+0x159>
jmp    129e <main+0x15e>
jmp    125d <main+0x11d>
jmp    12a3 <main+0x163>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%edx
lea    0xd61(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd4e(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <fscanf@plt>
mov    0x2d17(%rip),%rcx
cmp    (%rcx),%rax
jne    12df <main+0x19f>
jmp    12e4 <main+0x1a4>
jmp    12a3 <main+0x163>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xea4(%rip),%r14
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbp
lea    0xe85(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xe7c(%rip),%r12
mov    %rsp,%rdx
mov    %r15,0x8(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <fscanf@plt>
lea    0x4(%rsp),%r15
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <fscanf@plt>
lea    0xe52(%rip),%r13
mov    0x2e21(%rip),%r14
jmp    11ea <main+0xaa>
nopl   0x0(%rax)
call   1050 <fprintf@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
mov    %rsp,%rdx
call   1040 <fscanf@plt>
cmp    (%r14),%rax
je     120d <main+0xcd>
mov    (%rsp),%edx
mov    0x4(%rsp),%eax
mov    %rbx,%rdi
mov    %r13,%rsi
cmp    %eax,%edx
jl     11d0 <main+0x90>
mov    %eax,%edx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
jmp    11e0 <main+0xa0>
mov    %rbp,0x10(%rsp)
lea    0xdf9(%rip),%r12
lea    0xdef(%rip),%r13
mov    %rsp,%rbp
mov    0x8(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <fprintf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1040 <fscanf@plt>
cmp    (%r14),%rax
jne    1230 <main+0xf0>
lea    0xdba(%rip),%r12
lea    0xdb0(%rip),%r13
lea    0x4(%rsp),%r15
mov    0x10(%rsp),%rbp
nopl   0x0(%rax)
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <fprintf@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fscanf@plt>
cmp    (%r14),%rax
jne    1270 <main+0x130>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"2-DATA.out\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d \00"
@EOF = global i64 0
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*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %7
%19 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %8
%20 = load i32*, i32** %6
%21 = call i64 @fscanf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%22 = load i32*, i32** %7
%23 = call i64 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
br label %24
24: ; preds = %2, %48
%25 = load i32, i32* %9
%26 = load i32, i32* %10
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %38
28: ; preds = %24
%29 = load i32*, i32** %8
%30 = load i32, i32* %9
%31 = call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load i32*, i32** %6
%33 = call i64 @fscanf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%34 = load i64, i64* @EOF
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %28
br label %49
37: ; preds = %28
br label %48
38: ; preds = %24
%39 = load i32*, i32** %8
%40 = load i32, i32* %10
%41 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = load i32*, i32** %7
%43 = call i64 @fscanf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%44 = load i64, i64* @EOF
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %47
46: ; preds = %38
br label %49
47: ; preds = %38
br label %48
48: ; preds = %47, %37
br label %24
49: ; preds = %46, %36
br label %50
50: ; preds = %49, %59
%51 = load i32*, i32** %8
%52 = load i32, i32* %9
%53 = call i32 @fprintf(i32* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %52)
%54 = load i32*, i32** %6
%55 = call i64 @fscanf(i32* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%56 = load i64, i64* @EOF
%57 = icmp eq i64 %55, %56
br i1 %57, label %58, label %59
58: ; preds = %50
br label %60
59: ; preds = %50
br label %50
60: ; preds = %58
br label %61
61: ; preds = %60, %70
%62 = load i32*, i32** %8
%63 = load i32, i32* %10
%64 = call i32 @fprintf(i32* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %63)
%65 = load i32*, i32** %7
%66 = call i64 @fscanf(i32* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%67 = load i64, i64* @EOF
%68 = icmp eq i64 %66, %67
br i1 %68, label %69, label %70
69: ; preds = %61
br label %71
70: ; preds = %61
br label %61
71: ; preds = %69
%72 = load i32*, i32** %6
%73 = call i32 @fclose(i32* %72)
%74 = load i32*, i32** %7
%75 = call i32 @fclose(i32* %74)
%76 = load i32*, i32** %8
%77 = call i32 @fclose(i32* %76)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"2-DATA.out\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d \00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = bitcast i32* %3 to i8*
%13 = bitcast i32* %4 to i8*
%14 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%15 = call i64 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
br label %16
16: ; preds = %30, %2
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%22 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%23 = load i64, i64* @EOF
%24 = icmp eq i64 %22, %23
br i1 %24, label %31, label %30
25: ; preds = %16
%26 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%27 = call i64 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
br i1 %29, label %31, label %30
30: ; preds = %25, %20
br label %16
31: ; preds = %25, %20
br label %32
32: ; preds = %31, %32
%33 = load i32, i32* %3
%34 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%36 = load i64, i64* @EOF
%37 = icmp eq i64 %35, %36
br i1 %37, label %38, label %32
38: ; preds = %32, %38
%39 = load i32, i32* %4
%40 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = call i64 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%42 = load i64, i64* @EOF
%43 = icmp eq i64 %41, %42
br i1 %43, label %44, label %38
44: ; preds = %38
%45 = call i32 @fclose(i32* %7)
%46 = call i32 @fclose(i32* %10)
%47 = call i32 @fclose(i32* %11)
ret i32 0
}