#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*/ name2;
typedef int /*<<< orphan*/ name1;

/* Variables and functions */
int /*<<< orphan*/ choose_name(char *, int);
int /*<<< orphan*/ dorename(char *, char *);
scalar_t__ getpid();
int /*<<< orphan*/ say(char *, int, char *, char *);
void rename_proc(void) {
  char name1[32], name2[32];
  int ct;
  for (ct = 0; ct < 100; ct++) {
    choose_name(name1, sizeof(name1));
    choose_name(name2, sizeof(name2));
    say("pid %2d: rename %s -> %s\n", (int)getpid(), name1, name2);
    dorename(name1, name2);
  }
}


x86 assembly (clang, -O0):
<rename_proc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x44(%rbp)
cmpl   $0x64,-0x44(%rbp)
jge    11ad <rename_proc+0x6d>
lea    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1050 <choose_name@plt>
lea    -0x40(%rbp),%rdi
mov    $0x20,%esi
call   1050 <choose_name@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    -0x20(%rbp),%rdx
lea    -0x40(%rbp),%rcx
lea    0xe73(%rip),%rdi
call   1060 <say@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <dorename@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    114f <rename_proc+0xf>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rename_proc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    $0x64,%ebp
lea    0x20(%rsp),%r14
mov    %rsp,%rbx
lea    0xea2(%rip),%r15
xchg   %ax,%ax
mov    %r14,%rdi
mov    $0x20,%esi
call   1050 <choose_name@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <choose_name@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1060 <say@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <dorename@plt>
add    $0xffffffff,%ebp
jne    1160 <rename_proc+0x20>
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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