#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 atoi(char *);
char *calloc(int, int);
int /*<<< orphan*/ duffs_device(char *, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int i = atoi(argv[1]);
  char *from = "1234567890";
  char *to = calloc(1, 10);
  duffs_device(from, to, i);
  fprintf(stderr,
          "[INFO] (%s:%d) "
          "to is : %s"
          "\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/shmiluyu/LearncTheHardWay/refs/heads/"
          "master/duffsdevice.c",
          13, to);
  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
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    0xe93(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
mov    $0xa,%esi
call   1040 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <duffs_device@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%r8
lea    0xe63(%rip),%rsi
lea    0xe77(%rip),%rdx
mov    $0xd,%ecx
call   1050 <fprintf@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
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    $0x1,%edi
mov    $0xa,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
lea    0xe99(%rip),%rdi
mov    %rax,%rsi
mov    %ebp,%edx
call   1030 <duffs_device@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
lea    0xe9e(%rip),%rdx
mov    $0xd,%ecx
mov    %rbx,%r8
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"1234567890\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"[INFO] (%s:%d) to is : %s\0A\00"
@.str.2 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/shmiluyu/LearncTheHardWay/refs/heads/master/duffsdevice.c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %6
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %7
%13 = call i8* @calloc(i32 1, i32 10)
store i8* %13, i8** %8
%14 = load i8*, i8** %7
%15 = load i8*, i8** %8
%16 = load i32, i32* %6
%17 = call i32 @duffs_device(i8* %14, i8* %15, i32 %16)
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %8
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.2, i64 0, i64 0), i32 13, i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"1234567890\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"[INFO] (%s:%d) to is : %s\0A\00"
@.str.2 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/shmiluyu/LearncTheHardWay/refs/heads/master/duffsdevice.c\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = tail call dereferenceable_or_null(10) i8* @calloc(i32 1, i32 10)
%7 = tail call i32 @duffs_device(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %5)
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.2, i64 0, i64 0), i32 13, i8* %6)
ret i32 0
}