#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int);
int stat(char *, struct stat *);
void get_output_names(char *samples, char *procmap) {
  struct stat sb;
  int i, res;
  res = 0;
  for (i = 0; !(res); i++) {
    sprintf(samples, "prof%i.smpl", i);
    sprintf(procmap, "prof%i.map", i);
    res = stat(samples, &sb);
    res &= stat(procmap, &sb);
  }
}


x86 assembly (clang, -O0):
<get_output_names>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1154 <get_output_names+0x34>
jmp    11ab <get_output_names+0x8b>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe9e(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe97(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <stat@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <stat@plt>
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <get_output_names+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_output_names>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %ebp,%ebp
lea    0xed2(%rip),%r12
mov    %rsp,%r13
nopl   (%rax)
mov    %rbx,%rdi
lea    0xeb6(%rip),%rsi
mov    %ebp,%edx
call   1040 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <stat@plt>
mov    %eax,%r15d
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <stat@plt>
add    $0x1,%ebp
test   %r15d,%eax
je     1140 <get_output_names+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [12 x i8] c"prof%i.smpl\00"
@.str.1 = [11 x i8] c"prof%i.map\00"
define void @get_output_names(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.stat
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
store i32 0, i32* %6
br label %8
8: ; preds = %25, %2
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i32, i32* %6
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i8*, i8** %4
%17 = load i32, i32* %6
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i8*, i8** %3
%20 = call i32 @stat(i8* %19, %struct.stat* %5)
store i32 %20, i32* %7
%21 = load i8*, i8** %4
%22 = call i32 @stat(i8* %21, %struct.stat* %5)
%23 = load i32, i32* %7
%24 = and i32 %23, %22
store i32 %24, i32* %7
br label %25
25: ; preds = %12
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %8
28: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [12 x i8] c"prof%i.smpl\00"
@.str.1 = [11 x i8] c"prof%i.map\00"
define void @get_output_names(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
br label %5
5: ; preds = %2, %5
%6 = phi i32 [ 0, %2 ], [ %12, %5 ]
%7 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%9 = call i32 @stat(i8* %0, %struct.stat* %3)
%10 = call i32 @stat(i8* %1, %struct.stat* %3)
%11 = and i32 %10, %9
%12 = add nuw nsw i32 %6, 1
%13 = icmp eq i32 %11, 0
br i1 %13, label %5, label %14
14: ; preds = %5
ret void
}