#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 /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void g(char *input) {
  input[0] = 'H';
  printf("%s\n", input);
  input = "goodbye 2";
  printf("%s\n", input);
  char buf[16] = "goodbye 2.1";
  input = buf;
  input[0] = 'G';
  printf("%s\n", input);
  input = (char *)malloc(sizeof(char) * 16);
  strcpy(input, "goodbye 2.2");
  input[0] = 'G';
  printf("%s\n", input);
  free(input);
}


x86 assembly (clang, -O0):
<g>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x48,(%rax)
mov    -0x8(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9a(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
mov    0xe9b(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe98(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x47,(%rax)
mov    -0x8(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rax
movb   $0x47,(%rax)
mov    -0x8(%rbp),%rsi
lea    0xe1d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rsi
movb   $0x48,(%rdi)
lea    0xeac(%rip),%r14
mov    %r14,%rdi
call   1050 <printf@plt>
lea    0xea1(%rip),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
movaps 0xeae(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x47,(%rsp)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe75(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
movb   $0x47,(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [10 x i8] c"goodbye 2\00"
@__const.g.buf = [16 x i8] c"goodbye 2.1\00\00\00\00\00"
@.str.2 = [12 x i8] c"goodbye 2.2\00"
define void @g(i8* %0) {
%2 = alloca i8*
%3 = alloca [16 x i8]
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 0
store i8 72, i8* %5
%6 = load i8*, i8** %2
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = bitcast [16 x i8]* %3 to i8*
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 71, i8* %13
%14 = load i8*, i8** %2
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i64 @malloc(i32 16)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %2
%18 = load i8*, i8** %2
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 0
store i8 71, i8* %21
%22 = load i8*, i8** %2
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %2
%25 = call i32 @free(i8* %24)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [10 x i8] c"goodbye 2\00"
@__const.g.buf = [16 x i8] c"goodbye 2.1\00\00\00\00\00"
@.str.2 = [12 x i8] c"goodbye 2.2\00"
define void @g(i8* %0) {
%2 = alloca [16 x i8]
store i8 72, i8* %0
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
store i8 71, i8* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = call i64 @malloc(i32 16)
%8 = inttoptr i64 %7 to i8*
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i8 71, i8* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%11 = call i32 @free(i8* %8)
ret void
}