#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 *doit();
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int *f = doit();
  int j = 3;
  printf("%d %d\n", *f, j);
  char *buf = malloc(20);
  memset(buf, 'a', 19);
  buf[19] = '\0';
  free(buf);
  printf("%s\n", buf);
  free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <doit@plt>
mov    %rax,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x61,%esi
mov    $0x13,%edx
call   1050 <memset@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0x13(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1080 <doit@plt>
mov    (%rax),%esi
lea    0xe8f(%rip),%rdi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x61,%esi
mov    $0x13,%edx
call   1060 <memset@plt>
movb   $0x0,0x13(%rbx)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d %d\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i32* (...) @doit()
store i32* %5, i32** %2
store i32 3, i32* %3
%6 = load i32*, i32** %2
%7 = load i32, i32* %6
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = call i8* @malloc(i32 20)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 @memset(i8* %11, i8 signext 97, i32 19)
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 19
store i8 0, i8* %14
%15 = load i8*, i8** %4
%16 = call i32 @free(i8* %15)
%17 = load i8*, i8** %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %4
%20 = call i32 @free(i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = tail call i32* (...) @doit()
%2 = load i32, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %2, i32 3)
%4 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%5 = tail call i32 @memset(i8* %4, i8 signext 97, i32 19)
%6 = getelementptr inbounds i8, i8* %4, i64 19
store i8 0, i8* %6
%7 = tail call i32 @free(i8* %4)
%8 = tail call i32 @puts(i8* dereferenceable(1) %4)
%9 = tail call i32 @free(i8* %4)
ret i32 0
}