#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*/ logwtmp(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int wait(int /*<<< orphan*/);
void dologout() {
  int pid;
  while ((pid = wait(0)) > 0) {
    char line[100];
    sprintf(line, "uucp%.4d", pid);
    logwtmp(line, "", "");
  }
}


x86 assembly (clang, -O0):
<dologout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
xor    %edi,%edi
call   1050 <wait@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jle    1176 <dologout+0x46>
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xea7(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe9f(%rip),%rdx
mov    %rdx,%rsi
call   1030 <logwtmp@plt>
jmp    1138 <dologout+0x8>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dologout>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
xor    %edi,%edi
call   1050 <wait@plt>
test   %eax,%eax
jle    1186 <dologout+0x56>
lea    0xeb5(%rip),%r14
mov    %rsp,%r15
lea    0xeb3(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1030 <logwtmp@plt>
xor    %edi,%edi
call   1050 <wait@plt>
test   %eax,%eax
jg     1160 <dologout+0x30>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"uucp%.4d\00"
@.str.1 = [1 x i8] zeroinitializer
define void @dologout() {
%1 = alloca i32
%2 = alloca [100 x i8]
br label %3
3: ; preds = %6, %0
%4 = call i32 @wait(i32 0)
store i32 %4, i32* %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* %1
%9 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @logwtmp(i8* %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %3
12: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"uucp%.4d\00"
@.str.1 = [1 x i8] zeroinitializer
define void @dologout() {
%1 = alloca [100 x i8]
%2 = call i32 @wait(i32 0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %12
4: ; preds = %0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ %2, %4 ], [ %10, %6 ]
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @logwtmp(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @wait(i32 0)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %6, %0
ret void
}