#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;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int concate(FILE *fst_file, FILE *snd_file, FILE *out_file) {
  if (fst_file == NULL || snd_file == NULL || out_file == NULL)
    return 1;
  char cursor;
  for (cursor = fgetc(fst_file); cursor != EOF; cursor = fgetc(fst_file))
    fputc(cursor, out_file);
  for (cursor = fgetc(snd_file); cursor != EOF; cursor = fgetc(snd_file))
    fputc(cursor, out_file);
  return 0;
}


x86 assembly (clang, -O0):
<concate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1155 <concate+0x35>
cmpq   $0x0,-0x18(%rbp)
je     1155 <concate+0x35>
cmpq   $0x0,-0x20(%rbp)
jne    1161 <concate+0x41>
movl   $0x1,-0x4(%rbp)
jmp    11ec <concate+0xcc>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
mov    0x2e70(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11a3 <concate+0x83>
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x21(%rbp)
jmp    116d <concate+0x4d>
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
mov    0x2e2e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11e5 <concate+0xc5>
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x21(%rbp)
jmp    11af <concate+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concate>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%r15d
test   %rdi,%rdi
je     11a9 <concate+0x89>
mov    %rsi,%r14
test   %rsi,%rsi
je     11a9 <concate+0x89>
mov    %rdx,%rbx
test   %rdx,%rdx
je     11a9 <concate+0x89>
mov    %rdi,%rbp
call   1030 <fgetc@plt>
mov    0x2e96(%rip),%r12
cmp    (%r12),%al
je     1179 <concate+0x59>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    %rbp,%rdi
call   1030 <fgetc@plt>
cmp    (%r12),%al
jne    1160 <concate+0x40>
mov    %r14,%rdi
call   1030 <fgetc@plt>
xor    %r15d,%r15d
cmp    (%r12),%al
je     11a9 <concate+0x89>
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    (%r12),%al
jne    1190 <concate+0x70>
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @concate(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%9 = load i32*, i32** %5
%10 = icmp eq i32* %9, null
br i1 %10, label %17, label %11
11: ; preds = %3
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32*, i32** %7
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %18
17: ; preds = %14, %11, %3
store i32 1, i32* %4
br label %51
18: ; preds = %14
%19 = load i32*, i32** %5
%20 = call signext i8 @fgetc(i32* %19)
store i8 %20, i8* %8
br label %21
21: ; preds = %31, %18
%22 = load i8, i8* %8
%23 = sext i8 %22 to i32
%24 = load i8, i8* @EOF
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %23, %25
br i1 %26, label %27, label %34
27: ; preds = %21
%28 = load i8, i8* %8
%29 = load i32*, i32** %7
%30 = call i32 @fputc(i8 signext %28, i32* %29)
br label %31
31: ; preds = %27
%32 = load i32*, i32** %5
%33 = call signext i8 @fgetc(i32* %32)
store i8 %33, i8* %8
br label %21
34: ; preds = %21
%35 = load i32*, i32** %6
%36 = call signext i8 @fgetc(i32* %35)
store i8 %36, i8* %8
br label %37
37: ; preds = %47, %34
%38 = load i8, i8* %8
%39 = sext i8 %38 to i32
%40 = load i8, i8* @EOF
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %39, %41
br i1 %42, label %43, label %50
43: ; preds = %37
%44 = load i8, i8* %8
%45 = load i32*, i32** %7
%46 = call i32 @fputc(i8 signext %44, i32* %45)
br label %47
47: ; preds = %43
%48 = load i32*, i32** %6
%49 = call signext i8 @fgetc(i32* %48)
store i8 %49, i8* %8
br label %37
50: ; preds = %37
store i32 0, i32* %4
br label %51
51: ; preds = %50, %17
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @concate(i32* %0, i32* %1, i32* %2) {
%4 = icmp eq i32* %0, null
%5 = icmp eq i32* %1, null
%6 = or i1 %4, %5
%7 = icmp eq i32* %2, null
%8 = or i1 %6, %7
br i1 %8, label %29, label %9
9: ; preds = %3
%10 = tail call signext i8 @fgetc(i32* %0)
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %19, label %13
13: ; preds = %9, %13
%14 = phi i8 [ %16, %13 ], [ %10, %9 ]
%15 = tail call i32 @fputc(i8 signext %14, i32* %2)
%16 = tail call signext i8 @fgetc(i32* %0)
%17 = load i8, i8* @EOF
%18 = icmp eq i8 %16, %17
br i1 %18, label %19, label %13
19: ; preds = %13, %9
%20 = tail call signext i8 @fgetc(i32* %1)
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %29, label %23
23: ; preds = %19, %23
%24 = phi i8 [ %26, %23 ], [ %20, %19 ]
%25 = tail call i32 @fputc(i8 signext %24, i32* %2)
%26 = tail call signext i8 @fgetc(i32* %1)
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %26, %27
br i1 %28, label %29, label %23
29: ; preds = %23, %19, %3
%30 = phi i32 [ 1, %3 ], [ 0, %19 ], [ 0, %23 ]
ret i32 %30
}