#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_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncmp(char *, char *, int);
int write(int, char *, int);
int main(int argc, char **argv) {
  char *in_file = NULL;
  char *out_file = NULL;
  int in_fd = 1;
  int out_fd = 2;
  int count = -1;
  int bs = 512;
  int x;
  for (x = 1; x < argc; x++) {
    if (!strncmp("if=", argv[x], 3)) {
      in_file = argv[x] + 3;
    } else if (!strncmp("of=", argv[x], 3)) {
      out_file = argv[x] + 3;
    } else if (!strncmp("bs=", argv[x], 3)) {
      bs = atoi(argv[x] + 3);
    } else if (!strncmp("count=", argv[x], 6)) {
      count = atoi(argv[x] + 6);
    }
  }
  if (in_file) {
    in_fd = open(in_file, O_RDONLY);
    if (in_fd < 0) {
      printf("dd: no such file: %s\n", in_file);
      return -1;
    }
  }
  if (out_file) {
    out_fd = open(out_file, O_WRONLY | O_CREAT, 0644);
    if (out_fd < 0) {
      printf("dd: permission denied: %s\n", out_file);
      return -1;
    }
  }
  printf("count: %d\n", count);
  printf("bs:    %d\n", bs);
  if (in_file)
    printf("in:   %s\n", in_file);
  if (out_file)
    printf("out:  %s\n", out_file);
  char buff[bs];
  int done = 0;
  int blocks_total = 0;
  int bytes_transfered = 0;
  while (blocks_total != count) {
    if (blocks_total != 0 && blocks_total % 10 == 0)
      printf("Progress:  %d/%d blocks copied\n", blocks_total, count);
    int rb = 0;
    do {
      int res = read(in_fd, buff + rb, bs - rb);
      if (res <= 0) {
        done = 1;
        break;
      }
      rb += res;
    } while (rb != bs);
    int wb = 0;
    do {
      int res = write(out_fd, buff + wb, rb - wb);
      if (res < 0) {
        fprintf(stderr, "dd: write failed!\n");
        done = 1;
        break;
      }
      wb += res;
    } while (wb < rb);
    bytes_transfered += rb;
    if (done)
      break;
    blocks_total++;
  }
  printf("0x%x | %d bytes read\n", bytes_transfered, bytes_transfered);
  printf("0x%x | %d bytes written\n", bytes_transfered, bytes_transfered);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x2,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
movl   $0x200,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12e6 <main+0x176>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe28(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1204 <main+0x94>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
jmp    12d3 <main+0x163>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xded(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1243 <main+0xd3>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x3,%rax
mov    %rax,-0x20(%rbp)
jmp    12ce <main+0x15e>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdb2(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1286 <main+0x116>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x3,%rdi
call   1090 <atoi@plt>
mov    %eax,-0x30(%rbp)
jmp    12c9 <main+0x159>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd73(%rip),%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12c4 <main+0x154>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x6,%rdi
call   1090 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    12c9 <main+0x159>
jmp    12ce <main+0x15e>
jmp    12d3 <main+0x163>
jmp    12d8 <main+0x168>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b9 <main+0x49>
cmpq   $0x0,-0x18(%rbp)
je     1335 <main+0x1c5>
mov    -0x18(%rbp),%rdi
mov    0x2ce4(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1330 <main+0x1c0>
mov    -0x18(%rbp),%rsi
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1574 <main+0x404>
jmp    1335 <main+0x1c5>
cmpq   $0x0,-0x20(%rbp)
je     1392 <main+0x222>
mov    -0x20(%rbp),%rdi
mov    0x2c75(%rip),%rax
mov    (%rax),%esi
mov    0x2ca4(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    138d <main+0x21d>
mov    -0x20(%rbp),%rsi
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1574 <main+0x404>
jmp    1392 <main+0x222>
mov    -0x2c(%rbp),%esi
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     13d1 <main+0x261>
mov    -0x18(%rbp),%rsi
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     13ee <main+0x27e>
mov    -0x20(%rbp),%rsi
lea    0xc7d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     153e <main+0x3ce>
cmpl   $0x0,-0x50(%rbp)
je     1467 <main+0x2f7>
mov    -0x50(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1467 <main+0x2f7>
mov    -0x50(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xc0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x70(%rbp),%rsi
mov    -0x24(%rbp),%edi
movslq -0x58(%rbp),%rax
add    %rax,%rsi
mov    -0x30(%rbp),%edx
sub    -0x58(%rbp),%edx
call   1060 <read@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jg     14a0 <main+0x330>
movl   $0x1,-0x4c(%rbp)
jmp    14b5 <main+0x345>
mov    -0x5c(%rbp),%eax
add    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    146e <main+0x2fe>
movl   $0x0,-0x60(%rbp)
mov    -0x70(%rbp),%rsi
mov    -0x28(%rbp),%edi
movslq -0x60(%rbp),%rax
add    %rax,%rsi
mov    -0x58(%rbp),%edx
sub    -0x60(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    1503 <main+0x393>
mov    0x2ae7(%rip),%rax
mov    (%rax),%edi
lea    0xb9c(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4c(%rbp)
jmp    1518 <main+0x3a8>
mov    -0x64(%rbp),%eax
add    -0x60(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x58(%rbp),%eax
jl     14bc <main+0x34c>
mov    -0x58(%rbp),%eax
add    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1530 <main+0x3c0>
jmp    153e <main+0x3ce>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1429 <main+0x2b9>
mov    -0x54(%rbp),%esi
mov    -0x54(%rbp),%edx
lea    0xb56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x54(%rbp),%esi
mov    -0x54(%rbp),%edx
lea    0xb58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x2,-0x48(%rbp)
cmp    $0x2,%edi
jl     1271 <main+0x101>
mov    %rsi,%rbx
mov    %edi,%r15d
movl   $0xffffffff,-0x30(%rbp)
movl   $0x200,-0x34(%rbp)
mov    $0x1,%r13d
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
jmp    11d4 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
add    $0x3,%rsi
mov    %rsi,%r12
add    $0x1,%r13
cmp    %r13,%r15
je     1296 <main+0x126>
mov    (%rbx,%r13,8),%rsi
lea    0xe21(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    (%rbx,%r13,8),%rsi
test   %eax,%eax
je     11c0 <main+0x50>
lea    0xe0c(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    (%rbx,%r13,8),%rsi
test   %eax,%eax
je     1250 <main+0xe0>
lea    0xdf7(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    (%rbx,%r13,8),%rsi
test   %eax,%eax
je     125d <main+0xed>
lea    0xde2(%rip),%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11c7 <main+0x57>
mov    (%rbx,%r13,8),%rdi
add    $0x6,%rdi
call   1090 <atoi@plt>
mov    %eax,-0x30(%rbp)
jmp    11c7 <main+0x57>
nopl   (%rax)
add    $0x3,%rsi
mov    %rsi,-0x40(%rbp)
jmp    11c7 <main+0x57>
add    $0x3,%rsi
mov    %rsi,%rdi
call   1090 <atoi@plt>
mov    %eax,-0x34(%rbp)
jmp    11c7 <main+0x57>
mov    $0x1,%al
mov    %eax,-0x40(%rbp)
mov    $0x200,%r15d
mov    $0xffffffff,%r14d
movl   $0x1,-0x44(%rbp)
xor    %ebx,%ebx
xor    %r12d,%r12d
mov    $0x1,%r13b
jmp    132f <main+0x1bf>
test   %r12,%r12
sete   %r14b
je     12ca <main+0x15a>
mov    %r12,%rbx
mov    0x2d37(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <open@plt>
mov    %eax,-0x44(%rbp)
test   %eax,%eax
mov    -0x34(%rbp),%r15d
js     14c0 <main+0x350>
mov    %r14b,-0x2c(%rbp)
jmp    12dc <main+0x16c>
mov    %r14b,-0x2c(%rbp)
xor    %r12d,%r12d
movl   $0x1,-0x44(%rbp)
mov    -0x34(%rbp),%r15d
mov    -0x30(%rbp),%r14d
mov    -0x40(%rbp),%rbx
test   %rbx,%rbx
je     1324 <main+0x1b4>
mov    0x2cd0(%rip),%rax
mov    0x2d01(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
movl   $0x0,-0x40(%rbp)
mov    %rbx,%rdi
mov    $0x1a4,%edx
xor    %eax,%eax
call   1080 <open@plt>
mov    %eax,-0x48(%rbp)
test   %eax,%eax
jns    132b <main+0x1bb>
lea    0xd0a(%rip),%rdi
jmp    14c7 <main+0x357>
mov    $0x1,%al
mov    %eax,-0x40(%rbp)
xor    %ebx,%ebx
mov    -0x2c(%rbp),%r13b
lea    0xd0e(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd08(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r13b,%r13b
jne    1367 <main+0x1f7>
lea    0xcfd(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,-0x40(%rbp)
jne    137e <main+0x20e>
lea    0xcf0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,-0x50(%rbp)
mov    %r15d,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
xor    %ebx,%ebx
xor    %r13d,%r13d
mov    %r15d,-0x34(%rbp)
mov    %r14d,-0x30(%rbp)
cmp    %r14d,%ebx
je     148f <main+0x31f>
mov    %r13d,-0x40(%rbp)
test   %ebx,%ebx
je     13e1 <main+0x271>
mov    %ebx,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%ecx
sub    %eax,%ecx
jne    13e1 <main+0x271>
lea    0xc99(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,-0x2c(%rbp)
xor    %r14d,%r14d
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
movslq %r13d,%rbx
lea    (%r12,%rbx,1),%rsi
mov    %r15d,%edx
sub    %ebx,%edx
mov    -0x44(%rbp),%edi
call   1060 <read@plt>
test   %eax,%eax
mov    %eax,%r13d
mov    $0x0,%ecx
cmovle %ecx,%r13d
add    %ebx,%r13d
test   %eax,%eax
mov    $0x1,%eax
cmovle %eax,%r14d
jle    1427 <main+0x2b7>
cmp    %r15d,%r13d
jne    13f0 <main+0x280>
xor    %r15d,%r15d
mov    -0x48(%rbp),%ebx
nopl   (%rax)
movslq %r15d,%rax
lea    (%r12,%rax,1),%rsi
mov    %r13d,%edx
sub    %eax,%edx
mov    %ebx,%edi
call   1040 <write@plt>
test   %eax,%eax
js     1471 <main+0x301>
add    %eax,%r15d
cmp    %r13d,%r15d
jl     1430 <main+0x2c0>
mov    -0x40(%rbp),%ebx
add    %r13d,%ebx
mov    %ebx,%r13d
mov    -0x2c(%rbp),%ebx
add    $0x1,%ebx
test   %r14d,%r14d
mov    -0x34(%rbp),%r15d
mov    -0x30(%rbp),%r14d
je     13a3 <main+0x233>
jmp    148f <main+0x31f>
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
lea    0xc0d(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%ebx
add    %r13d,%ebx
mov    %ebx,%r13d
lea    0xc0b(%rip),%rdi
xor    %r14d,%r14d
mov    %r13d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc0a(%rip),%rdi
mov    %r13d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x50(%rbp),%rsp
jmp    14d7 <main+0x367>
lea    0xb4c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"if=\00"
@.str.1 = [4 x i8] c"of=\00"
@.str.2 = [4 x i8] c"bs=\00"
@.str.3 = [7 x i8] c"count=\00"
@O_RDONLY = global i32 0
@.str.4 = [22 x i8] c"dd: no such file: %s\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.5 = [27 x i8] c"dd: permission denied: %s\0A\00"
@.str.6 = [11 x i8] c"count: %d\0A\00"
@.str.7 = [11 x i8] c"bs: %d\0A\00"
@.str.8 = [10 x i8] c"in: %s\0A\00"
@.str.9 = [10 x i8] c"out: %s\0A\00"
@.str.10 = [32 x i8] c"Progress: %d/%d blocks copied\0A\00"
@stderr = global i32 0
@.str.11 = [19 x i8] c"dd: write failed!\0A\00"
@.str.12 = [22 x i8] c"0x%x | %d bytes read\0A\00"
@.str.13 = [25 x i8] c"0x%x | %d bytes written\0A\00"
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
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i32 1, i32* %8
store i32 2, i32* %9
store i32 -1, i32* %10
store i32 512, i32* %11
store i32 1, i32* %12
br label %22
22: ; preds = %92, %2
%23 = load i32, i32* %12
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %95
26: ; preds = %22
%27 = load i8**, i8*** %5
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %31, i32 3)
%33 = icmp ne i32 %32, 0
br i1 %33, label %41, label %34
34: ; preds = %26
%35 = load i8**, i8*** %5
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = getelementptr inbounds i8, i8* %39, i64 3
store i8* %40, i8** %6
br label %91
41: ; preds = %26
%42 = load i8**, i8*** %5
%43 = load i32, i32* %12
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %46, i32 3)
%48 = icmp ne i32 %47, 0
br i1 %48, label %56, label %49
49: ; preds = %41
%50 = load i8**, i8*** %5
%51 = load i32, i32* %12
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = getelementptr inbounds i8, i8* %54, i64 3
store i8* %55, i8** %7
br label %90
56: ; preds = %41
%57 = load i8**, i8*** %5
%58 = load i32, i32* %12
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %61, i32 3)
%63 = icmp ne i32 %62, 0
br i1 %63, label %72, label %64
64: ; preds = %56
%65 = load i8**, i8*** %5
%66 = load i32, i32* %12
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = getelementptr inbounds i8, i8* %69, i64 3
%71 = call i32 @atoi(i8* %70)
store i32 %71, i32* %11
br label %89
72: ; preds = %56
%73 = load i8**, i8*** %5
%74 = load i32, i32* %12
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8*, i8** %73, i64 %75
%77 = load i8*, i8** %76
%78 = call i32 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %77, i32 6)
%79 = icmp ne i32 %78, 0
br i1 %79, label %88, label %80
80: ; preds = %72
%81 = load i8**, i8*** %5
%82 = load i32, i32* %12
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = getelementptr inbounds i8, i8* %85, i64 6
%87 = call i32 @atoi(i8* %86)
store i32 %87, i32* %10
br label %88
88: ; preds = %80, %72
br label %89
89: ; preds = %88, %64
br label %90
90: ; preds = %89, %49
br label %91
91: ; preds = %90, %34
br label %92
92: ; preds = %91
%93 = load i32, i32* %12
%94 = add nsw i32 %93, 1
store i32 %94, i32* %12
br label %22
95: ; preds = %22
%96 = load i8*, i8** %6
%97 = icmp ne i8* %96, null
br i1 %97, label %98, label %108
98: ; preds = %95
%99 = load i8*, i8** %6
%100 = load i32, i32* @O_RDONLY
%101 = call i32 (i8*, i32, ...) @open(i8* %99, i32 %100)
store i32 %101, i32* %8
%102 = load i32, i32* %8
%103 = icmp slt i32 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %98
%105 = load i8*, i8** %6
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %105)
store i32 -1, i32* %3
br label %221
107: ; preds = %98
br label %108
108: ; preds = %107, %95
%109 = load i8*, i8** %7
%110 = icmp ne i8* %109, null
br i1 %110, label %111, label %123
111: ; preds = %108
%112 = load i8*, i8** %7
%113 = load i32, i32* @O_WRONLY
%114 = load i32, i32* @O_CREAT
%115 = or i32 %113, %114
%116 = call i32 (i8*, i32, ...) @open(i8* %112, i32 %115, i32 420)
store i32 %116, i32* %9
%117 = load i32, i32* %9
%118 = icmp slt i32 %117, 0
br i1 %118, label %119, label %122
119: ; preds = %111
%120 = load i8*, i8** %7
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %120)
store i32 -1, i32* %3
br label %221
122: ; preds = %111
br label %123
123: ; preds = %122, %108
%124 = load i32, i32* %10
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %124)
%126 = load i32, i32* %11
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %126)
%128 = load i8*, i8** %6
%129 = icmp ne i8* %128, null
br i1 %129, label %130, label %133
130: ; preds = %123
%131 = load i8*, i8** %6
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %131)
br label %133
133: ; preds = %130, %123
%134 = load i8*, i8** %7
%135 = icmp ne i8* %134, null
br i1 %135, label %136, label %139
136: ; preds = %133
%137 = load i8*, i8** %7
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* %137)
br label %139
139: ; preds = %136, %133
%140 = load i32, i32* %11
%141 = zext i32 %140 to i64
%142 = call i8* @llvm.stacksave()
store i8* %142, i8** %13
%143 = alloca i8, i64 %141
store i64 %141, i64* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
br label %144
144: ; preds = %210, %139
%145 = load i32, i32* %16
%146 = load i32, i32* %10
%147 = icmp ne i32 %145, %146
br i1 %147, label %148, label %213
148: ; preds = %144
%149 = load i32, i32* %16
%150 = icmp ne i32 %149, 0
br i1 %150, label %151, label %159
151: ; preds = %148
%152 = load i32, i32* %16
%153 = srem i32 %152, 10
%154 = icmp eq i32 %153, 0
br i1 %154, label %155, label %159
155: ; preds = %151
%156 = load i32, i32* %16
%157 = load i32, i32* %10
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %156, i32 %157)
br label %159
159: ; preds = %155, %151, %148
store i32 0, i32* %18
br label %160
160: ; preds = %176, %159
%161 = load i32, i32* %8
%162 = load i32, i32* %18
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i8, i8* %143, i64 %163
%165 = load i32, i32* %11
%166 = load i32, i32* %18
%167 = sub nsw i32 %165, %166
%168 = call i32 @read(i32 %161, i8* %164, i32 %167)
store i32 %168, i32* %19
%169 = load i32, i32* %19
%170 = icmp sle i32 %169, 0
br i1 %170, label %171, label %172
171: ; preds = %160
store i32 1, i32* %15
br label %180
172: ; preds = %160
%173 = load i32, i32* %19
%174 = load i32, i32* %18
%175 = add nsw i32 %174, %173
store i32 %175, i32* %18
br label %176
176: ; preds = %172
%177 = load i32, i32* %18
%178 = load i32, i32* %11
%179 = icmp ne i32 %177, %178
br i1 %179, label %160, label %180
180: ; preds = %176, %171
store i32 0, i32* %20
br label %181
181: ; preds = %199, %180
%182 = load i32, i32* %9
%183 = load i32, i32* %20
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds i8, i8* %143, i64 %184
%186 = load i32, i32* %18
%187 = load i32, i32* %20
%188 = sub nsw i32 %186, %187
%189 = call i32 @write(i32 %182, i8* %185, i32 %188)
store i32 %189, i32* %21
%190 = load i32, i32* %21
%191 = icmp slt i32 %190, 0
br i1 %191, label %192, label %195
192: ; preds = %181
%193 = load i32, i32* @stderr
%194 = call i32 @fprintf(i32 %193, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %15
br label %203
195: ; preds = %181
%196 = load i32, i32* %21
%197 = load i32, i32* %20
%198 = add nsw i32 %197, %196
store i32 %198, i32* %20
br label %199
199: ; preds = %195
%200 = load i32, i32* %20
%201 = load i32, i32* %18
%202 = icmp slt i32 %200, %201
br i1 %202, label %181, label %203
203: ; preds = %199, %192
%204 = load i32, i32* %18
%205 = load i32, i32* %17
%206 = add nsw i32 %205, %204
store i32 %206, i32* %17
%207 = load i32, i32* %15
%208 = icmp ne i32 %207, 0
br i1 %208, label %209, label %210
209: ; preds = %203
br label %213
210: ; preds = %203
%211 = load i32, i32* %16
%212 = add nsw i32 %211, 1
store i32 %212, i32* %16
br label %144
213: ; preds = %209, %144
%214 = load i32, i32* %17
%215 = load i32, i32* %17
%216 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i32 %214, i32 %215)
%217 = load i32, i32* %17
%218 = load i32, i32* %17
%219 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i32 %217, i32 %218)
store i32 0, i32* %3
%220 = load i8*, i8** %13
br label %221
221: ; preds = %213, %119, %104
%222 = load i32, i32* %3
ret i32 %222
}

LLVM IR (-O2):
@.str = [4 x i8] c"if=\00"
@.str.1 = [4 x i8] c"of=\00"
@.str.2 = [4 x i8] c"bs=\00"
@.str.3 = [7 x i8] c"count=\00"
@O_RDONLY = global i32 0
@.str.4 = [22 x i8] c"dd: no such file: %s\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.5 = [27 x i8] c"dd: permission denied: %s\0A\00"
@.str.6 = [11 x i8] c"count: %d\0A\00"
@.str.7 = [11 x i8] c"bs: %d\0A\00"
@.str.8 = [10 x i8] c"in: %s\0A\00"
@.str.9 = [10 x i8] c"out: %s\0A\00"
@.str.10 = [32 x i8] c"Progress: %d/%d blocks copied\0A\00"
@stderr = global i32 0
@.str.11 = [19 x i8] c"dd: write failed!\0A\00"
@.str.12 = [22 x i8] c"0x%x | %d bytes read\0A\00"
@.str.13 = [25 x i8] c"0x%x | %d bytes written\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %66
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %39
%7 = phi i64 [ 1, %4 ], [ %44, %39 ]
%8 = phi i8* [ null, %4 ], [ %43, %39 ]
%9 = phi i8* [ null, %4 ], [ %42, %39 ]
%10 = phi i32 [ 512, %4 ], [ %41, %39 ]
%11 = phi i32 [ -1, %4 ], [ %40, %39 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %7
%13 = load i8*, i8** %12
%14 = tail call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13, i32 3)
%15 = icmp eq i32 %14, 0
%16 = load i8*, i8** %12
br i1 %15, label %17, label %19
17: ; preds = %6
%18 = getelementptr inbounds i8, i8* %16, i64 3
br label %39
19: ; preds = %6
%20 = tail call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 3)
%21 = icmp eq i32 %20, 0
%22 = load i8*, i8** %12
br i1 %21, label %23, label %25
23: ; preds = %19
%24 = getelementptr inbounds i8, i8* %22, i64 3
br label %39
25: ; preds = %19
%26 = tail call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 3)
%27 = icmp eq i32 %26, 0
%28 = load i8*, i8** %12
br i1 %27, label %29, label %32
29: ; preds = %25
%30 = getelementptr inbounds i8, i8* %28, i64 3
%31 = tail call i32 @atoi(i8* %30)
br label %39
32: ; preds = %25
%33 = tail call i32 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %28, i32 6)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i8*, i8** %12
%37 = getelementptr inbounds i8, i8* %36, i64 6
%38 = tail call i32 @atoi(i8* %37)
br label %39
39: ; preds = %17, %29, %35, %32, %23
%40 = phi i32 [ %11, %32 ], [ %38, %35 ], [ %11, %29 ], [ %11, %23 ], [ %11, %17 ]
%41 = phi i32 [ %10, %32 ], [ %10, %35 ], [ %31, %29 ], [ %10, %23 ], [ %10, %17 ]
%42 = phi i8* [ %9, %32 ], [ %9, %35 ], [ %9, %29 ], [ %24, %23 ], [ %9, %17 ]
%43 = phi i8* [ %8, %32 ], [ %8, %35 ], [ %8, %29 ], [ %8, %23 ], [ %18, %17 ]
%44 = add nuw nsw i64 %7, 1
%45 = icmp eq i64 %44, %5
br i1 %45, label %46, label %6
46: ; preds = %39
%47 = icmp eq i8* %43, null
br i1 %47, label %54, label %48
48: ; preds = %46
%49 = load i32, i32* @O_RDONLY
%50 = tail call i32 (i8*, i32, ...) @open(i8* %43, i32 %49)
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %43)
br label %133
54: ; preds = %48, %46
%55 = phi i8* [ %43, %48 ], [ null, %46 ]
%56 = phi i32 [ %50, %48 ], [ 1, %46 ]
%57 = icmp eq i8* %42, null
br i1 %57, label %66, label %58
58: ; preds = %54
%59 = load i32, i32* @O_WRONLY
%60 = load i32, i32* @O_CREAT
%61 = or i32 %60, %59
%62 = tail call i32 (i8*, i32, ...) @open(i8* %42, i32 %61, i32 420)
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %58
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %42)
br label %133
66: ; preds = %2, %58, %54
%67 = phi i1 [ false, %58 ], [ true, %54 ], [ true, %2 ]
%68 = phi i32 [ %56, %58 ], [ %56, %54 ], [ 1, %2 ]
%69 = phi i32 [ %40, %58 ], [ %40, %54 ], [ -1, %2 ]
%70 = phi i32 [ %41, %58 ], [ %41, %54 ], [ 512, %2 ]
%71 = phi i8* [ %42, %58 ], [ null, %54 ], [ null, %2 ]
%72 = phi i8* [ %55, %58 ], [ %55, %54 ], [ null, %2 ]
%73 = phi i1 [ %47, %58 ], [ %47, %54 ], [ true, %2 ]
%74 = phi i32 [ %62, %58 ], [ 2, %54 ], [ 2, %2 ]
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %69)
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %70)
br i1 %73, label %79, label %77
77: ; preds = %66
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %72)
br label %79
79: ; preds = %77, %66
br i1 %67, label %82, label %80
80: ; preds = %79
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* %71)
br label %82
82: ; preds = %80, %79
%83 = zext i32 %70 to i64
%84 = tail call i8* @llvm.stacksave()
%85 = alloca i8, i64 %83
br label %86
86: ; preds = %125, %82
%87 = phi i32 [ 0, %82 ], [ %128, %125 ]
%88 = phi i32 [ 0, %82 ], [ %126, %125 ]
%89 = icmp eq i32 %87, %69
br i1 %89, label %129, label %90
90: ; preds = %86
%91 = icmp ne i32 %87, 0
%92 = urem i32 %87, 10
%93 = icmp eq i32 %92, 0
%94 = and i1 %91, %93
br i1 %94, label %95, label %97
95: ; preds = %90
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %87, i32 %69)
br label %97
97: ; preds = %95, %90
br label %98
98: ; preds = %97, %98
%99 = phi i32 [ %106, %98 ], [ 0, %97 ]
%100 = phi i32 [ %108, %98 ], [ 0, %97 ]
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %85, i64 %101
%103 = sub nsw i32 %70, %100
%104 = call i32 @read(i32 %68, i8* %102, i32 %103)
%105 = icmp slt i32 %104, 1
%106 = select i1 %105, i32 1, i32 %99
%107 = select i1 %105, i32 0, i32 %104
%108 = add nsw i32 %107, %100
%109 = icmp eq i32 %108, %70
%110 = select i1 %105, i1 true, i1 %109
br i1 %110, label %111, label %98
111: ; preds = %98, %122
%112 = phi i32 [ %123, %122 ], [ 0, %98 ]
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %85, i64 %113
%115 = sub nsw i32 %108, %112
%116 = call i32 @write(i32 %74, i8* %114, i32 %115)
%117 = icmp slt i32 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %111
%119 = load i32, i32* @stderr
%120 = tail call i32 @fprintf(i32 %119, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%121 = add nsw i32 %108, %88
br label %129
122: ; preds = %111
%123 = add nsw i32 %116, %112
%124 = icmp slt i32 %123, %108
br i1 %124, label %111, label %125
125: ; preds = %122
%126 = add nsw i32 %108, %88
%127 = icmp eq i32 %106, 0
%128 = add nuw nsw i32 %87, 1
br i1 %127, label %86, label %129
129: ; preds = %125, %86, %118
%130 = phi i32 [ %121, %118 ], [ %88, %86 ], [ %126, %125 ]
%131 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i32 %130, i32 %130)
%132 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i32 %130, i32 %130)
tail call void @llvm.stackrestore(i8* %84)
br label %133
133: ; preds = %129, %64, %52
%134 = phi i32 [ -1, %52 ], [ -1, %64 ], [ 0, %129 ]
ret i32 %134
}