#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*/ check_connectivity();
int /*<<< orphan*/ fsck_dir(int, char *);
scalar_t__ getenv(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int i;
  char *sha1_dir;
  if (argc != 1)
    usage("fsck-cache");
  sha1_dir = getenv("SHA1_FILE_DIRECTORY") ?: ".git/objects";
  for (i = 0; i < 256; i++) {
    static char dir[4096];
    sprintf(dir, "%s/%02x", sha1_dir, i);
    fsck_dir(i, dir);
  }
  check_connectivity();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     117c <main+0x2c>
lea    0xe89(%rip),%rdi
call   1050 <usage@plt>
lea    0xe88(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11a3 <main+0x53>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11b3 <main+0x63>
lea    0xe75(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11b3 <main+0x63>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    1206 <main+0xb6>
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0x2e83(%rip),%rdi
lea    0xe48(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x14(%rbp),%edi
lea    0x2e6d(%rip),%rsi
call   1060 <fsck_dir@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c2 <main+0x72>
mov    $0x0,%al
call   1040 <check_connectivity@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
je     1168 <main+0x18>
lea    0xe9d(%rip),%rdi
call   1050 <usage@plt>
lea    0xe9c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xea1(%rip),%r14
cmovne %rax,%r14
xor    %ebp,%ebp
lea    0x2ed5(%rip),%rbx
lea    0xe9a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1070 <sprintf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <fsck_dir@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    11a0 <main+0x50>
xor    %eax,%eax
call   1040 <check_connectivity@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"fsck-cache\00"
@.str.1 = [20 x i8] c"SHA1_FILE_DIRECTORY\00"
@.str.2 = [13 x i8] c".git/objects\00"
@main.dir = internal global [4096 x i8] zeroinitializer
@.str.3 = [8 x i8] c"%s/%02x\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @usage(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = call i64 @getenv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = inttoptr i64 %13 to i8*
br label %18
17: ; preds = %12
br label %18
18: ; preds = %17, %15
%19 = phi i8* [ %16, %15 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %17 ]
store i8* %19, i8** %7
store i32 0, i32* %6
br label %20
20: ; preds = %29, %18
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 256
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = load i32, i32* %6
%26 = call i32 @sprintf(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.dir, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %24, i32 %25)
%27 = load i32, i32* %6
%28 = call i32 @fsck_dir(i32 %27, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.dir, i64 0, i64 0))
br label %29
29: ; preds = %23
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %20
32: ; preds = %20
%33 = call i32 (...) @check_connectivity()
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"fsck-cache\00"
@.str.1 = [20 x i8] c"SHA1_FILE_DIRECTORY\00"
@.str.2 = [13 x i8] c".git/objects\00"
@main.dir = internal global [4096 x i8] zeroinitializer
@.str.3 = [8 x i8] c"%s/%02x\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @usage(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = tail call i64 @getenv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = inttoptr i64 %7 to i8*
%10 = select i1 %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %9
br label %11
11: ; preds = %6, %11
%12 = phi i32 [ 0, %6 ], [ %15, %11 ]
%13 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.dir, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %10, i32 %12)
%14 = tail call i32 @fsck_dir(i32 %12, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.dir, i64 0, i64 0))
%15 = add nuw nsw i32 %12, 1
%16 = icmp eq i32 %15, 256
br i1 %16, label %17, label %11
17: ; preds = %11
%18 = tail call i32 (...) @check_connectivity()
ret i32 0
}