#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*/ slog_csoup_format(char *, ...);
int /*<<< orphan*/ slog_csoup_puts(int /*<<< orphan*/, int, int /*<<< orphan*/);
int smm_fstat(char *);
int do_stat_file(char *path) {
  int rc;
  rc = smm_fstat(path);
  switch (rc) {
  case 0:
    slog_csoup_puts(0, (8 | 0), slog_csoup_format("%s: regular\n", path));
    break;
  case 1:
    slog_csoup_puts(0, (8 | 0), slog_csoup_format("%s: directory\n", path));
    break;
  case 3:
    slog_csoup_puts(0, (8 | 0), slog_csoup_format("%s: link\n", path));
    break;
  case 2:
    slog_csoup_puts(0, (8 | 0), slog_csoup_format("%s: device\n", path));
    break;
  }
  slog_csoup_puts(0, (8 | 0), slog_csoup_format("(%d)\n", rc));
  return 0;
}


x86 assembly (clang, -O0):
<do_stat_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <smm_fstat@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     11fc <do_stat_file+0xcc>
mov    -0x18(%rbp),%rax
lea    0xe9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1050 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1040 <slog_csoup_puts@plt>
jmp    11fc <do_stat_file+0xcc>
mov    -0x8(%rbp),%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1040 <slog_csoup_puts@plt>
jmp    11fc <do_stat_file+0xcc>
mov    -0x8(%rbp),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1050 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1040 <slog_csoup_puts@plt>
jmp    11fc <do_stat_file+0xcc>
mov    -0x8(%rbp),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1040 <slog_csoup_puts@plt>
mov    -0xc(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1040 <slog_csoup_puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_stat_file>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <smm_fstat@plt>
mov    %eax,%ebx
cmp    $0x3,%eax
ja     116c <do_stat_file+0x3c>
movslq %ebx,%rax
lea    0xeeb(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1040 <slog_csoup_puts@plt>
lea    0xebf(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1040 <slog_csoup_puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%s: regular\0A\00"
@.str.1 = [15 x i8] c"%s: directory\0A\00"
@.str.2 = [10 x i8] c"%s: link\0A\00"
@.str.3 = [12 x i8] c"%s: device\0A\00"
@.str.4 = [6 x i8] c"(%d)\0A\00"
define i32 @do_stat_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @smm_fstat(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
switch i32 %6, label %23 [
i32 0, label %7
i32 1, label %11
i32 3, label %15
i32 2, label %19
]
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %9)
br label %23
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %13)
br label %23
15: ; preds = %1
%16 = load i8*, i8** %2
%17 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %17)
br label %23
19: ; preds = %1
%20 = load i8*, i8** %2
%21 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %21)
br label %23
23: ; preds = %1, %19, %15, %11, %7
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s: regular\0A\00"
@.str.1 = [15 x i8] c"%s: directory\0A\00"
@.str.2 = [10 x i8] c"%s: link\0A\00"
@.str.3 = [12 x i8] c"%s: device\0A\00"
@.str.4 = [6 x i8] c"(%d)\0A\00"
@reltable.do_stat_file = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.do_stat_file to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.do_stat_file to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.do_stat_file to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.do_stat_file to i64)) to i32)]
define i32 @do_stat_file(i8* %0) {
%2 = tail call i32 @smm_fstat(i8* %0)
%3 = icmp ult i32 %2, 4
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.do_stat_file to i8*), i64 %6)
%8 = tail call i32 (i8*, ...) @slog_csoup_format(i8* %7, i8* %0)
%9 = tail call i32 @slog_csoup_puts(i32 0, i32 8, i32 %8)
br label %10
10: ; preds = %1, %4
%11 = tail call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %2)
%12 = tail call i32 @slog_csoup_puts(i32 0, i32 8, i32 %11)
ret i32 0
}