#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(int *);
int /*<<< orphan*/ func_slave();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
void func_master() {
  char *name = "function master";
  printf("%s\n", name);
  int *data;
  int num = 3;
  data = (int *)malloc(sizeof(int) * num);
  for (int i = 0; i < num; i++) {
    data[i] = i;
  }
  free(data);
  func_slave();
}


x86 assembly (clang, -O0):
<func_master>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
movl   $0x3,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ac <func_master+0x6c>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1184 <func_master+0x44>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1060 <func_slave@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func_master>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <printf@plt>
mov    $0xc,%edi
call   1050 <malloc@plt>
movabs $0x100000000,%rcx
mov    %rcx,(%rax)
movl   $0x2,0x8(%rax)
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <func_slave@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"function master\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @func_master() {
%1 = alloca i8*
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %1
%5 = load i8*, i8** %1
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
store i32 3, i32* %3
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = mul i64 4, %8
%10 = trunc i64 %9 to i32
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %2
store i32 0, i32* %4
br label %13
13: ; preds = %23, %0
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32, i32* %4
%19 = load i32*, i32** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
br label %23
23: ; preds = %17
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %13
26: ; preds = %13
%27 = load i32*, i32** %2
%28 = call i32 @free(i32* %27)
%29 = call i32 (...) @func_slave()
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"function master\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @func_master() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @malloc(i32 12)
%3 = inttoptr i64 %2 to i32*
store i32 0, i32* %3
%4 = getelementptr inbounds i32, i32* %3, i64 1
store i32 1, i32* %4
%5 = getelementptr inbounds i32, i32* %3, i64 2
store i32 2, i32* %5
%6 = tail call i32 @free(i32* %3)
%7 = tail call i32 (...) @func_slave()
ret void
}