#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 O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int open(char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char **argv) {
  int fd_hex, fd_char;
  int bytes_write;
  char buffer_hex[3] = {0x11, 0x22, 0x33};
  char buffer_char[3] = {'1', '2', '3'};
  if (argc != 3) {
    fprintf(stderr, "Usage:%s fromfile tofile/n/a", argv[0]);
    exit(1);
  }
  if ((fd_hex = open(argv[1], O_RDONLY | O_WRONLY)) == -1) {
    fprintf(stderr, "Open %s Error:%s/n", argv[1], strerror(errno));
    exit(1);
  }
  if ((fd_char = open(argv[2], O_RDONLY | O_WRONLY)) == -1) {
    fprintf(stderr, "Open %s Error:%s/n", argv[1], strerror(errno));
    exit(1);
  }
  bytes_write = write(fd_hex, buffer_hex, 3);
  bytes_write = write(fd_char, buffer_char, 3);
  close(fd_hex);
  close(fd_char);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe83(%rip),%ax
mov    %ax,-0x1f(%rbp)
mov    0xe7b(%rip),%al
mov    %al,-0x1d(%rbp)
mov    0xe72(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    0xe6a(%rip),%al
mov    %al,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11d0 <main+0x70>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e09(%rip),%rax
mov    (%rax),%esi
mov    0x2dd8(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1243 <main+0xe3>
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d96(%rip),%rax
mov    (%rax),%esi
mov    0x2d65(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    12b6 <main+0x156>
mov    0x2d63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    %rax,%rcx
lea    0xd7e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x1f(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x22(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
movb   $0x33,0x6(%rsp)
movw   $0x2211,0x4(%rsp)
movb   $0x33,0x2(%rsp)
movw   $0x3231,(%rsp)
cmp    $0x3,%edi
jne    11f9 <main+0x99>
mov    0x8(%rbx),%rdi
mov    0x2e57(%rip),%r14
mov    0x2e28(%rip),%r15
mov    (%r15),%esi
or     (%r14),%esi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     11be <main+0x5e>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
mov    (%r15),%esi
or     (%r14),%esi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
jne    121d <main+0xbd>
mov    0x2e13(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rbx),%rbx
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe43(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdfa(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %eax,%r14d
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
mov    $0x3,%edx
call   1030 <write@plt>
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0x3,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    %r14d,%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@__const.main.buffer_hex = [3 x i8] c"\11\223"
@__const.main.buffer_char = [3 x i8] c"123"
@stderr = global i32 0
@.str = [29 x i8] c"Usage:%s fromfile tofile/n/a\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@.str.1 = [19 x i8] c"Open %s Error:%s/n\00"
@errno = global i32 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 [3 x i8]
%10 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [3 x i8]* %9 to i8*
%12 = bitcast [3 x i8]* %10 to i8*
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i32, i32* @O_RDONLY
%27 = load i32, i32* @O_WRONLY
%28 = or i32 %26, %27
%29 = call i32 @open(i8* %25, i32 %28)
store i32 %29, i32* %6
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %40
31: ; preds = %22
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i32, i32* @errno
%37 = call i8* @strerror(i32 %36)
%38 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %35, i8* %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %22
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = load i32, i32* @O_RDONLY
%45 = load i32, i32* @O_WRONLY
%46 = or i32 %44, %45
%47 = call i32 @open(i8* %43, i32 %46)
store i32 %47, i32* %7
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %58
49: ; preds = %40
%50 = load i32, i32* @stderr
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = load i32, i32* @errno
%55 = call i8* @strerror(i32 %54)
%56 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %53, i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %40
%59 = load i32, i32* %6
%60 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%61 = call i32 @write(i32 %59, i8* %60, i32 3)
store i32 %61, i32* %8
%62 = load i32, i32* %7
%63 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%64 = call i32 @write(i32 %62, i8* %63, i32 3)
store i32 %64, i32* %8
%65 = load i32, i32* %6
%66 = call i32 @close(i32 %65)
%67 = load i32, i32* %7
%68 = call i32 @close(i32 %67)
%69 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@__const.main.buffer_hex = [3 x i8] c"\11\223"
@__const.main.buffer_char = [3 x i8] c"123"
@stderr = global i32 0
@.str = [29 x i8] c"Usage:%s fromfile tofile/n/a\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@.str.1 = [19 x i8] c"Open %s Error:%s/n\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = load i32, i32* @O_WRONLY
%18 = or i32 %17, %16
%19 = tail call i32 @open(i8* %15, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %28
21: ; preds = %13
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %14
%24 = load i32, i32* @errno
%25 = tail call i8* @strerror(i32 %24)
%26 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %25)
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %13
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = load i32, i32* @O_RDONLY
%32 = load i32, i32* @O_WRONLY
%33 = or i32 %32, %31
%34 = tail call i32 @open(i8* %30, i32 %33)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %43
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %14
%39 = load i32, i32* @errno
%40 = tail call i8* @strerror(i32 %39)
%41 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %38, i8* %40)
%42 = tail call i32 @exit(i32 1)
unreachable
43: ; preds = %28
%44 = call i32 @write(i32 %19, i8* %5, i32 3)
%45 = call i32 @write(i32 %34, i8* %6, i32 3)
%46 = tail call i32 @close(i32 %19)
%47 = tail call i32 @close(i32 %34)
%48 = tail call i32 @exit(i32 0)
unreachable
}