#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ strcat(char *, char const *);
void tests_cat_pid(char *buf, const char *name, pid_t pid) {
  char *p;
  unsigned x;
  const char digits[] = "0123456789";
  char pid_buf[64];
  x = (unsigned)pid;
  p = pid_buf + 64;
  *--p = '\0';
  if (x)
    while (x) {
      *--p = digits[x % 10];
      x /= 10;
    }
  else
    *--p = '0';
  buf[0] = '\0';
  strcat(buf, name);
  strcat(buf, p);
}


x86 assembly (clang, -O0):
<tests_cat_pid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xed5(%rip),%rax
mov    %rax,-0x2f(%rbp)
mov    0xed2(%rip),%ax
mov    %ax,-0x27(%rbp)
mov    0xeca(%rip),%al
mov    %al,-0x25(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x24(%rbp)
lea    -0x70(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,-0x1(%rax)
cmpl   $0x0,-0x24(%rbp)
je     11bf <tests_cat_pid+0xaf>
jmp    1178 <tests_cat_pid+0x68>
cmpl   $0x0,-0x24(%rbp)
je     11ba <tests_cat_pid+0xaa>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%eax
mov    -0x2f(%rbp,%rax,1),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x24(%rbp)
jmp    1178 <tests_cat_pid+0x68>
jmp    11d2 <tests_cat_pid+0xc2>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x30,-0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcat@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tests_cat_pid>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%r14
movb   $0x0,0x3f(%rsp)
test   %edx,%edx
je     1169 <tests_cat_pid+0x59>
lea    0x3f(%rsp),%rbx
mov    $0xcccccccd,%r8d
lea    0xecb(%rip),%r9
cs nopw 0x0(%rax,%rax,1)
nop
mov    %edx,%edi
imul   %r8,%rdi
shr    $0x23,%rdi
lea    (%rdi,%rdi,1),%eax
lea    (%rax,%rax,4),%eax
mov    %edx,%ecx
sub    %eax,%ecx
movzbl (%rcx,%r9,1),%eax
mov    %al,-0x1(%rbx)
add    $0xffffffffffffffff,%rbx
cmp    $0xa,%edx
mov    %edi,%edx
jae    1140 <tests_cat_pid+0x30>
jmp    1173 <tests_cat_pid+0x63>
lea    0x3e(%rsp),%rbx
movb   $0x30,0x3e(%rsp)
movb   $0x0,(%r14)
mov    %r14,%rdi
call   1030 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcat@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.tests_cat_pid.digits = [11 x i8] c"0123456789\00"
define void @tests_cat_pid(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [11 x i8]
%10 = alloca [64 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%11 = bitcast [11 x i8]* %9 to i8*
%12 = load i64, i64* %6
%13 = trunc i64 %12 to i32
store i32 %13, i32* %8
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%15 = getelementptr inbounds i8, i8* %14, i64 64
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i32 -1
store i8* %17, i8** %7
store i8 0, i8* %17
%18 = load i32, i32* %8
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %35
20: ; preds = %3
br label %21
21: ; preds = %24, %20
%22 = load i32, i32* %8
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i32, i32* %8
%26 = urem i32 %25, 10
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i32 -1
store i8* %31, i8** %7
store i8 %29, i8* %31
%32 = load i32, i32* %8
%33 = udiv i32 %32, 10
store i32 %33, i32* %8
br label %21
34: ; preds = %21
br label %38
35: ; preds = %3
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i32 -1
store i8* %37, i8** %7
store i8 48, i8* %37
br label %38
38: ; preds = %35, %34
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 0
store i8 0, i8* %40
%41 = load i8*, i8** %4
%42 = load i8*, i8** %5
%43 = call i32 @strcat(i8* %41, i8* %42)
%44 = load i8*, i8** %4
%45 = load i8*, i8** %7
%46 = call i32 @strcat(i8* %44, i8* %45)
ret void
}

LLVM IR (-O2):
@__const.tests_cat_pid.digits = [11 x i8] c"0123456789\00"
define void @tests_cat_pid(i8* %0, i8* %1, i64 %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = trunc i64 %2 to i32
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 63
store i8 0, i8* %7
%8 = icmp eq i32 %6, 0
br i1 %8, label %19, label %9
9: ; preds = %3, %9
%10 = phi i32 [ %17, %9 ], [ %6, %3 ]
%11 = phi i8* [ %16, %9 ], [ %7, %3 ]
%12 = urem i32 %10, 10
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [11 x i8], [11 x i8]* @__const.tests_cat_pid.digits, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %11, i64 -1
store i8 %15, i8* %16
%17 = udiv i32 %10, 10
%18 = icmp ult i32 %10, 10
br i1 %18, label %21, label %9
19: ; preds = %3
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 62
store i8 48, i8* %20
br label %21
21: ; preds = %9, %19
%22 = phi i8* [ %20, %19 ], [ %16, %9 ]
store i8 0, i8* %0
%23 = tail call i32 @strcat(i8* %0, i8* %1)
%24 = call i32 @strcat(i8* %0, i8* %22)
ret void
}