#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 */
typedef int /*<<< orphan*/ data;

/* Variables and functions */
scalar_t__ common_strrepl(char *, int, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  char data[20] = "asdfooasd";
  if (common_strrepl(data, sizeof(data), argv[1], argv[2]) < 0) {
    printf("Failed\n");
    return -1;
  }
  printf("Result: %s\n", data);
  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    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xebe(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
mov    $0x14,%esi
call   1040 <common_strrepl@plt>
cmp    $0x0,%rax
jge    1197 <main+0x77>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <main+0x90>
lea    -0x30(%rbp),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    0x8(%rsi),%rdx
mov    0x10(%rsi),%rcx
mov    %rsp,%rdi
mov    $0x14,%esi
call   1050 <common_strrepl@plt>
test   %rax,%rax
js     1177 <main+0x47>
lea    0xeab(%rip),%rdi
xor    %ebx,%ebx
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1188 <main+0x58>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.data = [20 x i8] c"asdfooasd\00\00\00\00\00\00\00\00\00\00\00"
@.str = [8 x i8] c"Failed\0A\00"
@.str.1 = [12 x i8] c"Result: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast [20 x i8]* %6 to i8*
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i64 @common_strrepl(i8* %8, i32 20, i8* %11, i8* %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %22
19: ; preds = %2
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 0, i32* %3
br label %22
22: ; preds = %19, %17
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@__const.main.data = [20 x i8] c"asdfooasd\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [12 x i8] c"Result: %s\0A\00"
@str = [7 x i8] c"Failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = call i64 @common_strrepl(i8* %4, i32 20, i8* %6, i8* %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ -1, %11 ], [ 0, %13 ]
ret i32 %16
}