#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*/ O_RDONLY;
int catvars(char *, char *, int, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ read(int, char *, int);
int main(int argc, char **argv) {
  char *input;
  char *buf2;
  int ret;
  int len1, len2;
  int fd = open(argv[1], O_RDONLY);
  input = malloc(sizeof(char) * 256);
  read(fd, input, 256);
  len1 = input[0];
  len2 = input[3];
  ret = catvars(input, input, len1, len2);
  free(input);
  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
mov    0x2e73(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x30(%rbp)
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x100,%edx
call   1050 <read@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl 0x3(%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1040 <catvars@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,%ebp
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    $0x100,%edx
call   1050 <read@plt>
movsbl (%rbx),%edx
movsbl 0x3(%rbx),%ecx
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1040 <catvars@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_RDONLY
%16 = call i32 @open(i8* %14, i32 %15)
store i32 %16, i32* %11
%17 = call i8* @malloc(i32 256)
store i8* %17, i8** %6
%18 = load i32, i32* %11
%19 = load i8*, i8** %6
%20 = call i32 @read(i32 %18, i8* %19, i32 256)
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
store i32 %24, i32* %9
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
store i32 %28, i32* %10
%29 = load i8*, i8** %6
%30 = load i8*, i8** %6
%31 = load i32, i32* %9
%32 = load i32, i32* %10
%33 = call i32 @catvars(i8* %29, i8* %30, i32 %31, i32 %32)
store i32 %33, i32* %8
%34 = load i8*, i8** %6
%35 = call i32 @free(i8* %34)
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* %4, i32 %5)
%7 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%8 = tail call i32 @read(i32 %6, i8* %7, i32 256)
%9 = load i8, i8* %7
%10 = sext i8 %9 to i32
%11 = getelementptr inbounds i8, i8* %7, i64 3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = tail call i32 @catvars(i8* %7, i8* %7, i32 %10, i32 %13)
%15 = tail call i32 @free(i8* %7)
ret i32 0
}