#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ join(char *, char *, char *, char, char);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char duplicate_delimiter;
  if (argc < 4) {
    fprintf(stderr, "Usage: %s file1 file2 delimiter [duplicate_delimiter]\n",
            argv[0]);
    exit(1);
  }
  if (argc == 5)
    duplicate_delimiter = *argv[4];
  else
    duplicate_delimiter = ',';
  join(argv[0], argv[1], argv[2], *argv[3], duplicate_delimiter);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1176 <main+0x46>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe99(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
cmpl   $0x5,-0x8(%rbp)
jne    1192 <main+0x62>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
jmp    1196 <main+0x66>
movb   $0x2c,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%al
movsbl %al,%ecx
movsbl -0x11(%rbp),%r8d
call   1050 <join@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x3,%edi
jle    1167 <main+0x37>
mov    $0x2c,%r8b
cmp    $0x5,%edi
jne    1145 <main+0x15>
mov    0x20(%rsi),%rax
mov    (%rax),%r8b
mov    (%rsi),%rdi
mov    0x8(%rsi),%rax
mov    0x10(%rsi),%rdx
mov    0x18(%rsi),%rcx
movsbl (%rcx),%ecx
movsbl %r8b,%r8d
mov    %rax,%rsi
call   1050 <join@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe86(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [55 x i8] c"Usage: %s file1 file2 delimiter [duplicate_delimiter]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 5
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 4
%22 = load i8*, i8** %21
%23 = load i8, i8* %22
store i8 %23, i8* %6
br label %25
24: ; preds = %16
store i8 44, i8* %6
br label %25
25: ; preds = %24, %19
%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 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = load i8, i8* %37
%39 = load i8, i8* %6
%40 = call i32 @join(i8* %28, i8* %31, i8* %34, i8 signext %38, i8 signext %39)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [55 x i8] c"Usage: %s file1 file2 delimiter [duplicate_delimiter]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = icmp eq i32 %0, 5
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = getelementptr inbounds i8*, i8** %1, i64 4
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
br label %15
15: ; preds = %9, %11
%16 = phi i8 [ %14, %11 ], [ 44, %9 ]
%17 = load i8*, i8** %1
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 3
%23 = load i8*, i8** %22
%24 = load i8, i8* %23
%25 = tail call i32 @join(i8* %17, i8* %19, i8* %21, i8 signext %24, i8 signext %16)
ret i32 0
}