#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*/ dormdir(char *);
scalar_t__ getpid();
int /*<<< orphan*/ say(char *, int, char *);
void rmdir_proc(void) {
  char name[32];
  int ct;
  for (ct = 0; ct < 100; ct++) {
    choose_name(name, sizeof(name));
    say("pid %2d: rmdir  %s\n", (int)getpid(), name);
    dormdir(name);
  }
}


x86 assembly (clang, -O0):
<rmdir_proc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    1197 <rmdir_proc+0x57>
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    0xe85(%rip),%rdi
call   1060 <say@plt>
lea    -0x20(%rbp),%rdi
call   1050 <dormdir@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114f <rmdir_proc+0xf>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rmdir_proc>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x64,%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 <dormdir@plt>
add    $0xffffffff,%ebp
jne    1160 <rmdir_proc+0x20>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"pid %2d: rmdir %s\0A\00"
define void @rmdir_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, 100
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 @dormdir(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: rmdir %s\0A\00"
define void @rmdir_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 @dormdir(i8* %2)
%10 = add nuw nsw i32 %4, 1
%11 = icmp eq i32 %10, 100
br i1 %11, label %12, label %3
12: ; preds = %3
ret void
}