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

/* Variables and functions */
int /*<<< orphan*/ choose_name(char *, int);
int /*<<< orphan*/ domkdir(char *);
scalar_t__ getpid();
int /*<<< orphan*/ say(char *, int, char *);
void mkdir_proc(void) {
  char name[32];
  int ct;
  for (ct = 0; ct < 10000; ct++) {
    choose_name(name, sizeof(name));
    say("pid %2d: mkdir  %s\n", (int)getpid(), name);
    domkdir(name);
  }
}


x86 assembly (clang, -O0):
<mkdir_proc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x24(%rbp)
cmpl   $0x2710,-0x24(%rbp)
jge    119a <mkdir_proc+0x5a>
lea    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1040 <choose_name@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    -0x20(%rbp),%rdx
lea    0xe82(%rip),%rdi
call   1060 <say@plt>
lea    -0x20(%rbp),%rdi
call   1050 <domkdir@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114f <mkdir_proc+0xf>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkdir_proc>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x2710,%ebp
mov    %rsp,%rbx
lea    0xea9(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <choose_name@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1060 <say@plt>
mov    %rbx,%rdi
call   1050 <domkdir@plt>
add    $0xffffffff,%ebp
jne    1160 <mkdir_proc+0x20>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"pid %2d: mkdir %s\0A\00"
define void @mkdir_proc() {
%1 = alloca [32 x i8]
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %15, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 10000
br i1 %5, label %6, label %18
6: ; preds = %3
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%8 = call i32 @choose_name(i8* %7, i32 32)
%9 = call i64 (...) @getpid()
%10 = trunc i64 %9 to i32
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%12 = call i32 @say(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %11)
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%14 = call i32 @domkdir(i8* %13)
br label %15
15: ; preds = %6
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %3
18: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"pid %2d: mkdir %s\0A\00"
define void @mkdir_proc() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %10, %3 ]
%5 = call i32 @choose_name(i8* %2, i32 32)
%6 = call i64 (...) @getpid()
%7 = trunc i64 %6 to i32
%8 = call i32 @say(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %2)
%9 = call i32 @domkdir(i8* %2)
%10 = add nuw nsw i32 %4, 1
%11 = icmp eq i32 %10, 10000
br i1 %11, label %12, label %3
12: ; preds = %3
ret void
}