#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ get_comm_name(char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ set_comm_name(char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    printf("I want 3 arguments");
    return -1;
  }
  memcpy(argv[0], "hidden_prog", strlen(argv[0]));
  memcpy(argv[1], "xxxxxxxxxxxxxxxx", strlen(argv[1]));
  memcpy(argv[2], "yyyyyyyyyyyyyyyy", strlen(argv[2]));
  char buf[64];
  get_comm_name(buf, sizeof(buf));
  printf("old_comm = %s", buf);
  set_comm_name("hidden_prog", 11);
  get_comm_name(buf, sizeof(buf));
  printf("new_comm = %s", buf);
  sleep(1000);
  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)
cmpl   $0x3,-0x8(%rbp)
je     119a <main+0x3a>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127b <main+0x11b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%edx
lea    0xe55(%rip),%rsi
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%edx
lea    0xe36(%rip),%rsi
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%edx
lea    0xe1c(%rip),%rsi
call   1050 <memcpy@plt>
lea    -0x50(%rbp),%rdi
mov    $0x40,%esi
call   1060 <get_comm_name@plt>
lea    -0x50(%rbp),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd3(%rip),%rdi
mov    $0xb,%esi
call   1080 <set_comm_name@plt>
lea    -0x50(%rbp),%rdi
mov    $0x40,%esi
call   1060 <get_comm_name@plt>
lea    -0x50(%rbp),%rsi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x3e8,%edi
call   1070 <sleep@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
cmp    $0x3,%edi
jne    1227 <main+0xc7>
mov    %rsi,%rbp
mov    (%rsi),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe8d(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    0x8(%rbp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    0x10(%rbp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1060 <get_comm_name@plt>
lea    0xe5d(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0xb,%esi
call   1080 <set_comm_name@plt>
mov    %rbx,%rdi
mov    $0x40,%esi
call   1060 <get_comm_name@plt>
lea    0xe3e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3e8,%edi
call   1070 <sleep@plt>
jmp    123a <main+0xda>
lea    0xdd2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"I want 3 arguments\00"
@.str.1 = [12 x i8] c"hidden_prog\00"
@.str.2 = [17 x i8] c"xxxxxxxxxxxxxxxx\00"
@.str.3 = [17 x i8] c"yyyyyyyyyyyyyyyy\00"
@.str.4 = [14 x i8] c"old_comm = %s\00"
@.str.5 = [14 x i8] c"new_comm = %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %46
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @memcpy(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @strlen(i8* %25)
%27 = call i32 @memcpy(i8* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @strlen(i8* %33)
%35 = call i32 @memcpy(i8* %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%37 = call i32 @get_comm_name(i8* %36, i32 64)
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = call i32 @set_comm_name(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 11)
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%42 = call i32 @get_comm_name(i8* %41, i32 64)
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = call i32 @sleep(i32 1000)
store i32 0, i32* %3
br label %46
46: ; preds = %11, %9
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [19 x i8] c"I want 3 arguments\00"
@.str.1 = [12 x i8] c"hidden_prog\00"
@.str.2 = [17 x i8] c"xxxxxxxxxxxxxxxx\00"
@.str.3 = [17 x i8] c"yyyyyyyyyyyyyyyy\00"
@.str.4 = [14 x i8] c"old_comm = %s\00"
@.str.5 = [14 x i8] c"new_comm = %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = icmp eq i32 %0, 3
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %26
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 @strlen(i8* %8)
%10 = tail call i32 @memcpy(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @strlen(i8* %12)
%14 = tail call i32 @memcpy(i8* %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @strlen(i8* %16)
%18 = tail call i32 @memcpy(i8* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%20 = call i32 @get_comm_name(i8* %19, i32 64)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %19)
%22 = call i32 @set_comm_name(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 11)
%23 = call i32 @get_comm_name(i8* %19, i32 64)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%25 = call i32 @sleep(i32 1000)
br label %26
26: ; preds = %7, %5
%27 = phi i32 [ -1, %5 ], [ 0, %7 ]
ret i32 %27
}