#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 FileEntry {
  int dummy;
};

/* Variables and functions */
char *getStatusText(int const);
int list(struct FileEntry **);
int /*<<< orphan*/ printf(char *, ...);
int list_log(struct FileEntry **result) {
  const int status = list(result);
  printf("LIST: ");
  status > 0 ? printf("%d FILES\n", status)
             : printf("%s\n", getStatusText(status));
  return status;
}


x86 assembly (clang, -O0):
<list_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <list@plt>
mov    %eax,-0xc(%rbp)
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1176 <list_log+0x46>
mov    -0xc(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118f <list_log+0x5f>
mov    -0xc(%rbp),%edi
call   1050 <getStatusText@plt>
mov    %rax,%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_log>:
push   %rbx
call   1050 <list@plt>
mov    %eax,%ebx
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    116c <list_log+0x2c>
lea    0xea6(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117b <list_log+0x3b>
mov    %ebx,%edi
call   1060 <getStatusText@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.FileEntry = type { i32 }
@.str = [7 x i8] c"LIST: \00"
@.str.1 = [10 x i8] c"%d FILES\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @list_log(%struct.FileEntry** %0) {
%2 = alloca %struct.FileEntry**
%3 = alloca i32
store %struct.FileEntry** %0, %struct.FileEntry*** %2
%4 = load %struct.FileEntry**, %struct.FileEntry*** %2
%5 = call i32 @list(%struct.FileEntry** %4)
store i32 %5, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %16
12: ; preds = %1
%13 = load i32, i32* %3
%14 = call i8* @getStatusText(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %12, %9
%17 = phi i32 [ %11, %9 ], [ %15, %12 ]
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
%struct.FileEntry = type { i32 }
@.str = [7 x i8] c"LIST: \00"
@.str.1 = [10 x i8] c"%d FILES\0A\00"
define i32 @list_log(%struct.FileEntry** %0) {
%2 = tail call i32 @list(%struct.FileEntry** %0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %2)
br label %10
7: ; preds = %1
%8 = tail call i8* @getStatusText(i32 %2)
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
br label %10
10: ; preds = %7, %5
ret i32 %2
}