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

/* Variables and functions */
int /*<<< orphan*/ dostat(struct minix_fs_dat *, char *);
int /*<<< orphan*/ printf(char *, char *);
void cmd_stat(struct minix_fs_dat *fs, int argc, char **argv) {
  if (argc == 1) {
    dostat(fs, ".");
  } else if (argc == 2) {
    dostat(fs, argv[1]);
  } else {
    int i;
    for (i = 1; i < argc; i++) {
      printf("%s:\n", argv[i]);
      dostat(fs, argv[i]);
    }
  }
}


x86 assembly (clang, -O0):
<cmd_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1152 <cmd_stat+0x32>
mov    -0x8(%rbp),%rdi
lea    0xeb8(%rip),%rsi
call   1030 <dostat@plt>
jmp    11ca <cmd_stat+0xaa>
cmpl   $0x2,-0xc(%rbp)
jne    1172 <cmd_stat+0x52>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <dostat@plt>
jmp    11c5 <cmd_stat+0xa5>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c0 <cmd_stat+0xa0>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <dostat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1179 <cmd_stat+0x59>
jmp    11c5 <cmd_stat+0xa5>
jmp    11ca <cmd_stat+0xaa>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_stat>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
cmp    $0x1,%esi
je     113f <cmd_stat+0x1f>
mov    %rdx,%r13
cmp    $0x2,%esi
jne    1157 <cmd_stat+0x37>
mov    0x8(%r13),%rsi
jmp    1146 <cmd_stat+0x26>
lea    0xeba(%rip),%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <dostat@plt>
jl     1193 <cmd_stat+0x73>
mov    %esi,%r12d
mov    $0x1,%ebx
lea    0xe9a(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbx,8),%rsi
mov    %r15,%rdi
call   1040 <printf@plt>
mov    0x0(%r13,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <dostat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <cmd_stat+0x50>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.minix_fs_dat = type { i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [5 x i8] c"%s:\0A\00"
define void @cmd_stat(%struct.minix_fs_dat* %0, i32 %1, i8** %2) {
%4 = alloca %struct.minix_fs_dat*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
store %struct.minix_fs_dat* %0, %struct.minix_fs_dat** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load %struct.minix_fs_dat*, %struct.minix_fs_dat** %4
%12 = call i32 @dostat(%struct.minix_fs_dat* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %46
13: ; preds = %3
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load %struct.minix_fs_dat*, %struct.minix_fs_dat** %4
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @dostat(%struct.minix_fs_dat* %17, i8* %20)
br label %45
22: ; preds = %13
store i32 1, i32* %7
br label %23
23: ; preds = %41, %22
%24 = load i32, i32* %7
%25 = load i32, i32* %5
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %44
27: ; preds = %23
%28 = load i8**, i8*** %6
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = load %struct.minix_fs_dat*, %struct.minix_fs_dat** %4
%35 = load i8**, i8*** %6
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @dostat(%struct.minix_fs_dat* %34, i8* %39)
br label %41
41: ; preds = %27
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %23
44: ; preds = %23
br label %45
45: ; preds = %44, %16
br label %46
46: ; preds = %45, %10
ret void
}

LLVM IR (-O2):
%struct.minix_fs_dat = type { i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [5 x i8] c"%s:\0A\00"
define void @cmd_stat(%struct.minix_fs_dat* %0, i32 %1, i8** nocapture %2) {
switch i32 %1, label %4 [
i32 1, label %20
i32 2, label %8
]
4: ; preds = %3
%5 = icmp sgt i32 %1, 1
br i1 %5, label %6, label %23
6: ; preds = %4
%7 = zext i32 %1 to i64
br label %11
8: ; preds = %3
%9 = getelementptr inbounds i8*, i8** %2, i64 1
%10 = load i8*, i8** %9
br label %20
11: ; preds = %6, %11
%12 = phi i64 [ 1, %6 ], [ %18, %11 ]
%13 = getelementptr inbounds i8*, i8** %2, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %13
%17 = tail call i32 @dostat(%struct.minix_fs_dat* %0, i8* %16)
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %23, label %11
20: ; preds = %3, %8
%21 = phi i8* [ %10, %8 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %3 ]
%22 = tail call i32 @dostat(%struct.minix_fs_dat* %0, i8* %21)
br label %23
23: ; preds = %11, %20, %4
ret void
}