#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 */
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char **argv) {
  char *p;
  if (argc == 1) {
    p = malloc(sizeof(char) * 2);
    strncpy(p, "y\0", 1);
  } else {
    p = malloc(sizeof(argv[1] + sizeof(char)));
    strcpy(p, argv[1]);
    strncat(p, "\0", 1);
  }
  while (1)
    printf("%s\n", p);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1198 <main+0x48>
mov    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe77(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
jmp    11cc <main+0x7c>
mov    $0x8,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe41(%rip),%rsi
mov    $0x1,%edx
call   1060 <strncat@plt>
jmp    11d1 <main+0x81>
mov    -0x18(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1050 <printf@plt>
jmp    11d1 <main+0x81>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    117c <main+0x2c>
mov    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe93(%rip),%rsi
mov    %rax,%rdi
mov    $0x1,%edx
call   1030 <strncpy@plt>
jmp    11ac <main+0x5c>
mov    %rsi,%r14
mov    $0x8,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%r14),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1060 <strncat@plt>
lea    0xe52(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
jmp    11c0 <main+0x70>

LLVM IR (-O0):
@.str = [3 x i8] c"y\00\00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = call i8* @malloc(i32 2)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = call i32 @strncpy(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1)
br label %22
13: ; preds = %2
%14 = call i8* @malloc(i32 8)
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcpy(i8* %15, i8* %18)
%20 = load i8*, i8** %6
%21 = call i32 @strncat(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %22
22: ; preds = %13, %9
br label %23
23: ; preds = %22, %23
%24 = load i8*, i8** %6
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %23
}

LLVM IR (-O2):
@.str = [3 x i8] c"y\00\00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call dereferenceable_or_null(2) i8* @malloc(i32 2)
%6 = tail call i32 @strncpy(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1)
br label %13
7: ; preds = %2
%8 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strcpy(i8* %8, i8* %10)
%12 = tail call i32 @strncat(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %13
13: ; preds = %7, %4
%14 = phi i8* [ %5, %4 ], [ %8, %7 ]
br label %15
15: ; preds = %15, %13
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %15
}