#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 */
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sha1_wrapper(char *, unsigned char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
int sha1_check(char *filename) {
  int i;
  size_t n;
  FILE *f;
  int nb_err1, nb_err2;
  int nb_tot1, nb_tot2;
  unsigned char sum[20];
  char buf[41], line[1024];
  if ((f = fopen(filename, "rb")) == NULL) {
    printf("failed to open: %s\n", filename);
    return (1);
  }
  nb_err1 = nb_err2 = 0;
  nb_tot1 = nb_tot2 = 0;
  memset(line, 0, sizeof(line));
  n = sizeof(line);
  while (fgets(line, n - 1, f) != NULL) {
    n = strlen(line);
    if (n < 44)
      continue;
    if (line[40] != ' ' || line[41] != ' ')
      continue;
    if (line[n - 1] == '\n') {
      n--;
      line[n] = '\0';
    }
    if (line[n - 1] == '\r') {
      n--;
      line[n] = '\0';
    }
    nb_tot1++;
    if (sha1_wrapper(line + 42, sum) != 0) {
      nb_err1++;
      continue;
    }
    nb_tot2++;
    for (i = 0; i < 20; i++)
      sprintf(buf + i * 2, "%02x", sum[i]);
    if (memcmp(line, buf, 40) != 0) {
      nb_err2++;
      fprintf(stderr, "wrong checksum: %s\n", line + 42);
    }
    n = sizeof(line);
  }
  if (nb_err1 != 0) {
    printf("WARNING: %d (out of %d) input files could "
           "not be read\n",
           nb_err1, nb_tot1);
  }
  if (nb_err2 != 0) {
    printf("WARNING: %d (out of %d) computed checksums did "
           "not match\n",
           nb_err2, nb_tot2);
  }
  return (nb_err1 != 0 || nb_err2 != 0);
}


x86 assembly (clang, -O0):
<sha1_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11db <sha1_check+0x4b>
mov    -0x10(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    141a <sha1_check+0x28a>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x480(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
movq   $0x400,-0x20(%rbp)
lea    -0x480(%rbp),%rdi
mov    -0x20(%rbp),%rsi
sub    $0x1,%rsi
mov    -0x28(%rbp),%rdx
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     13b1 <sha1_check+0x221>
lea    -0x480(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x2c,-0x20(%rbp)
jae    1254 <sha1_check+0xc4>
jmp    1212 <sha1_check+0x82>
movsbl -0x458(%rbp),%eax
cmp    $0x20,%eax
jne    1274 <sha1_check+0xe4>
movsbl -0x457(%rbp),%eax
cmp    $0x20,%eax
je     1279 <sha1_check+0xe9>
jmp    1212 <sha1_check+0x82>
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
movsbl -0x480(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    12aa <sha1_check+0x11a>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,-0x480(%rbp,%rax,1)
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
movsbl -0x480(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
jne    12db <sha1_check+0x14b>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,-0x480(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    -0x480(%rbp),%rdi
add    $0x2a,%rdi
lea    -0x50(%rbp),%rsi
call   1030 <sha1_wrapper@plt>
cmp    $0x0,%rax
je     1310 <sha1_check+0x180>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1212 <sha1_check+0x82>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    135c <sha1_check+0x1cc>
lea    -0x80(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
movslq -0x14(%rbp),%rax
lea    0xcd3(%rip),%rsi
movzbl -0x50(%rbp,%rax,1),%edx
call   10b0 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1320 <sha1_check+0x190>
lea    -0x480(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x28,%edx
call   1070 <memcmp@plt>
cmp    $0x0,%rax
je     13a4 <sha1_check+0x214>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
lea    -0x480(%rbp),%rdx
add    $0x2a,%rdx
lea    0xc7d(%rip),%rsi
call   1090 <fprintf@plt>
movq   $0x400,-0x20(%rbp)
jmp    1212 <sha1_check+0x82>
cmpl   $0x0,-0x2c(%rbp)
je     13cf <sha1_check+0x23f>
mov    -0x2c(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x30(%rbp)
je     13ed <sha1_check+0x25d>
mov    -0x30(%rbp),%esi
mov    -0x38(%rbp),%edx
lea    0xc81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x481(%rbp)
jne    140c <sha1_check+0x27c>
cmpl   $0x0,-0x30(%rbp)
setne  %al
mov    %al,-0x481(%rbp)
mov    -0x481(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sha1_check>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x468,%rsp
mov    %rdi,%rbp
lea    0xe55(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     14c4 <sha1_check+0x334>
mov    %rax,%rbx
lea    0x60(%rsp),%rbp
xor    %r12d,%r12d
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    $0x3ff,%esi
mov    %rbp,%rdi
mov    %rbx,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     14dc <sha1_check+0x34c>
lea    0x60(%rsp),%r15
lea    0xe1f(%rip),%r13
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %esi,%esi
mov    %esi,0x2c(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    $0x2b,%rax
jbe    1232 <sha1_check+0xa2>
cmpb   $0x20,0x88(%rsp)
20
jne    1232 <sha1_check+0xa2>
cmpb   $0x20,0x89(%rsp)
20
je     124e <sha1_check+0xbe>
add    $0xffffffffffffffff,%rax
mov    %r15,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    1210 <sha1_check+0x80>
jmp    148d <sha1_check+0x2fd>
mov    %r14d,0xc(%rsp)
lea    -0x1(%rax),%r14
movzbl 0x5f(%rsp,%rax,1),%edx
cmp    $0xa,%dl
jne    1279 <sha1_check+0xe9>
movb   $0x0,0x5f(%rsp,%rax,1)
mov    %rax,%rcx
add    $0xfffffffffffffffe,%rcx
movzbl 0x5e(%rsp,%rax,1),%edx
cmp    $0xd,%dl
je     1284 <sha1_check+0xf4>
jmp    128c <sha1_check+0xfc>
mov    %r14,%rcx
mov    %rax,%r14
cmp    $0xd,%dl
jne    128c <sha1_check+0xfc>
movb   $0x0,0x60(%rsp,%rcx,1)
mov    %rcx,%r14
addl   $0x1,0xc(%rsp)
lea    0x8a(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <sha1_wrapper@plt>
test   %rax,%rax
jne    1462 <sha1_check+0x2d2>
movzbl 0x10(%rsp),%edx
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x11(%rsp),%edx
lea    0x32(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x12(%rsp),%edx
lea    0x34(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x13(%rsp),%edx
lea    0x36(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x14(%rsp),%edx
lea    0x38(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x15(%rsp),%edx
lea    0x3a(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x16(%rsp),%edx
lea    0x3c(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x17(%rsp),%edx
lea    0x3e(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x18(%rsp),%edx
lea    0x40(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x19(%rsp),%edx
lea    0x42(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x1a(%rsp),%edx
lea    0x44(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x1b(%rsp),%edx
lea    0x46(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x1c(%rsp),%edx
lea    0x48(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x1d(%rsp),%edx
lea    0x4a(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x1e(%rsp),%edx
lea    0x4c(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x1f(%rsp),%edx
lea    0x4e(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x20(%rsp),%edx
lea    0x50(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x21(%rsp),%edx
lea    0x52(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x22(%rsp),%edx
lea    0x54(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
movzbl 0x23(%rsp),%edx
lea    0x56(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <sprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x28,%edx
call   1070 <memcmp@plt>
test   %rax,%rax
je     144c <sha1_check+0x2bc>
add    $0x1,%ebp
mov    0x2baa(%rip),%rax
mov    (%rax),%edi
lea    0xbdd(%rip),%rsi
lea    0x8a(%rsp),%rdx
call   1090 <fprintf@plt>
mov    0xc(%rsp),%r14d
add    $0x1,%r12d
mov    $0x3ff,%esi
mov    %r15,%rdi
jmp    123c <sha1_check+0xac>
addl   $0x1,0x2c(%rsp)
add    $0xffffffffffffffff,%r14
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    0x2c(%rsp),%esi
test   %rax,%rax
mov    0xc(%rsp),%r14d
jne    11ff <sha1_check+0x6f>
jmp    1495 <sha1_check+0x305>
mov    0x2c(%rsp),%esi
test   %esi,%esi
je     14e0 <sha1_check+0x350>
lea    0xb94(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%bl
test   %ebp,%ebp
je     14e6 <sha1_check+0x356>
lea    0xbb4(%rip),%rdi
mov    %ebp,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12b
jmp    14e9 <sha1_check+0x359>
lea    0xb38(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%eax
jmp    14f0 <sha1_check+0x360>
xor    %ebx,%ebx
jmp    14e9 <sha1_check+0x359>
xor    %ebx,%ebx
test   %ebp,%ebp
jne    14ac <sha1_check+0x31c>
xor    %r12d,%r12d
or     %bl,%r12b
movzbl %r12b,%eax
add    $0x468,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [20 x i8] c"failed to open: %s\0A\00"
@.str.2 = [5 x i8] c"%02x\00"
@stderr = global i32 0
@.str.3 = [20 x i8] c"wrong checksum: %s\0A\00"
@.str.4 = [55 x i8] c"WARNING: %d (out of %d) input files could not be read\0A\00"
@.str.5 = [58 x i8] c"WARNING: %d (out of %d) computed checksums did not match\0A\00"
define i32 @sha1_check(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [20 x i8]
%12 = alloca [41 x i8]
%13 = alloca [1024 x i8]
store i8* %0, i8** %3
%14 = load i8*, i8** %3
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %6
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = load i8*, i8** %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %18)
store i32 1, i32* %2
br label %138
20: ; preds = %1
store i32 0, i32* %8
store i32 0, i32* %7
store i32 0, i32* %10
store i32 0, i32* %9
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%22 = call i32 @memset(i8* %21, i32 0, i32 1024)
store i64 1024, i64* %5
br label %23
23: ; preds = %114, %79, %46, %35, %20
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%25 = load i64, i64* %5
%26 = sub i64 %25, 1
%27 = load i32*, i32** %6
%28 = call i32* @fgets(i8* %24, i64 %26, i32* %27)
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %115
30: ; preds = %23
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%32 = call i64 @strlen(i8* %31)
store i64 %32, i64* %5
%33 = load i64, i64* %5
%34 = icmp ult i64 %33, 44
br i1 %34, label %35, label %36
35: ; preds = %30
br label %23
36: ; preds = %30
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 40
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 32
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 32
br i1 %45, label %46, label %47
46: ; preds = %41, %36
br label %23
47: ; preds = %41
%48 = load i64, i64* %5
%49 = sub i64 %48, 1
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 10
br i1 %53, label %54, label %59
54: ; preds = %47
%55 = load i64, i64* %5
%56 = add i64 %55, -1
store i64 %56, i64* %5
%57 = load i64, i64* %5
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %57
store i8 0, i8* %58
br label %59
59: ; preds = %54, %47
%60 = load i64, i64* %5
%61 = sub i64 %60, 1
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 13
br i1 %65, label %66, label %71
66: ; preds = %59
%67 = load i64, i64* %5
%68 = add i64 %67, -1
store i64 %68, i64* %5
%69 = load i64, i64* %5
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %69
store i8 0, i8* %70
br label %71
71: ; preds = %66, %59
%72 = load i32, i32* %9
%73 = add nsw i32 %72, 1
store i32 %73, i32* %9
%74 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%75 = getelementptr inbounds i8, i8* %74, i64 42
%76 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%77 = call i64 @sha1_wrapper(i8* %75, i8* %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %71
%80 = load i32, i32* %7
%81 = add nsw i32 %80, 1
store i32 %81, i32* %7
br label %23
82: ; preds = %71
%83 = load i32, i32* %10
%84 = add nsw i32 %83, 1
store i32 %84, i32* %10
store i32 0, i32* %4
br label %85
85: ; preds = %99, %82
%86 = load i32, i32* %4
%87 = icmp slt i32 %86, 20
br i1 %87, label %88, label %102
88: ; preds = %85
%89 = getelementptr inbounds [41 x i8], [41 x i8]* %12, i64 0, i64 0
%90 = load i32, i32* %4
%91 = mul nsw i32 %90, 2
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %89, i64 %92
%94 = load i32, i32* %4
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %95
%97 = load i8, i8* %96
%98 = call i32 @sprintf(i8* %93, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %97)
br label %99
99: ; preds = %88
%100 = load i32, i32* %4
%101 = add nsw i32 %100, 1
store i32 %101, i32* %4
br label %85
102: ; preds = %85
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%104 = getelementptr inbounds [41 x i8], [41 x i8]* %12, i64 0, i64 0
%105 = call i64 @memcmp(i8* %103, i8* %104, i32 40)
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %114
107: ; preds = %102
%108 = load i32, i32* %8
%109 = add nsw i32 %108, 1
store i32 %109, i32* %8
%110 = load i32, i32* @stderr
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%112 = getelementptr inbounds i8, i8* %111, i64 42
%113 = call i32 @fprintf(i32 %110, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %112)
br label %114
114: ; preds = %107, %102
store i64 1024, i64* %5
br label %23
115: ; preds = %23
%116 = load i32, i32* %7
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %115
%119 = load i32, i32* %7
%120 = load i32, i32* %9
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %119, i32 %120)
br label %122
122: ; preds = %118, %115
%123 = load i32, i32* %8
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %129
125: ; preds = %122
%126 = load i32, i32* %8
%127 = load i32, i32* %10
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i32 %126, i32 %127)
br label %129
129: ; preds = %125, %122
%130 = load i32, i32* %7
%131 = icmp ne i32 %130, 0
br i1 %131, label %135, label %132
132: ; preds = %129
%133 = load i32, i32* %8
%134 = icmp ne i32 %133, 0
br label %135
135: ; preds = %132, %129
%136 = phi i1 [ true, %129 ], [ %134, %132 ]
%137 = zext i1 %136 to i32
store i32 %137, i32* %2
br label %138
138: ; preds = %135, %17
%139 = load i32, i32* %2
ret i32 %139
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [20 x i8] c"failed to open: %s\0A\00"
@.str.2 = [5 x i8] c"%02x\00"
@stderr = global i32 0
@.str.3 = [20 x i8] c"wrong checksum: %s\0A\00"
@.str.4 = [55 x i8] c"WARNING: %d (out of %d) input files could not be read\0A\00"
@.str.5 = [58 x i8] c"WARNING: %d (out of %d) computed checksums did not match\0A\00"
define i32 @sha1_check(i8* %0) {
%2 = alloca [20 x i8]
%3 = alloca [41 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %181
12: ; preds = %1
%13 = call i32 @memset(i8* %7, i32 0, i32 1024)
%14 = call i32* @fgets(i8* %7, i64 1023, i32* %8)
%15 = icmp eq i32* %14, null
br i1 %15, label %176, label %16
16: ; preds = %12
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 40
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 41
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 42
%20 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 2
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 1
%22 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 4
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 2
%24 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 6
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 3
%26 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 8
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 4
%28 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 10
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 5
%30 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 12
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 6
%32 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 14
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 7
%34 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 16
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 8
%36 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 18
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 9
%38 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 20
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 10
%40 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 22
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 11
%42 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 24
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 12
%44 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 26
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 13
%46 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 28
%47 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 14
%48 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 30
%49 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 15
%50 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 32
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 16
%52 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 34
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 17
%54 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 36
%55 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 18
%56 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 38
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 19
br label %58
58: ; preds = %16, %101
%59 = phi i32 [ 0, %16 ], [ %64, %101 ]
%60 = phi i32 [ 0, %16 ], [ %98, %101 ]
%61 = phi i32 [ 0, %16 ], [ %66, %101 ]
%62 = phi i32 [ 0, %16 ], [ %102, %101 ]
br label %63
63: ; preds = %58, %154
%64 = phi i32 [ %59, %58 ], [ %147, %154 ]
%65 = phi i32 [ %60, %58 ], [ %98, %154 ]
%66 = phi i32 [ %61, %58 ], [ %155, %154 ]
br label %67
67: ; preds = %63, %70
%68 = call i64 @strlen(i8* %7)
%69 = icmp ult i64 %68, 44
br i1 %69, label %70, label %74
70: ; preds = %67, %74
%71 = add i64 %68, -1
%72 = call i32* @fgets(i8* %7, i64 %71, i32* %8)
%73 = icmp eq i32* %72, null
br i1 %73, label %158, label %67
74: ; preds = %67
%75 = load i8, i8* %17
%76 = icmp ne i8 %75, 32
%77 = load i8, i8* %18
%78 = icmp ne i8 %77, 32
%79 = select i1 %76, i1 true, i1 %78
br i1 %79, label %70, label %80
80: ; preds = %74
%81 = add i64 %68, -1
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = icmp eq i8 %83, 10
br i1 %84, label %85, label %89
85: ; preds = %80
store i8 0, i8* %82
%86 = add i64 %68, -2
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %86
%88 = load i8, i8* %87
br label %89
89: ; preds = %85, %80
%90 = phi i8 [ %88, %85 ], [ %83, %80 ]
%91 = phi i64 [ %86, %85 ], [ %81, %80 ]
%92 = phi i64 [ %81, %85 ], [ %68, %80 ]
%93 = icmp eq i8 %90, 13
br i1 %93, label %94, label %96
94: ; preds = %89
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %91
store i8 0, i8* %95
br label %96
96: ; preds = %94, %89
%97 = phi i64 [ %91, %94 ], [ %92, %89 ]
%98 = add nsw i32 %65, 1
%99 = call i64 @sha1_wrapper(i8* %19, i8* %5)
%100 = icmp eq i64 %99, 0
br i1 %100, label %106, label %101
101: ; preds = %96
%102 = add nuw nsw i32 %62, 1
%103 = add i64 %97, -1
%104 = call i32* @fgets(i8* %7, i64 %103, i32* %8)
%105 = icmp eq i32* %104, null
br i1 %105, label %163, label %58
106: ; preds = %96
%107 = load i8, i8* %5
%108 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %107)
%109 = load i8, i8* %21
%110 = call i32 @sprintf(i8* %20, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %109)
%111 = load i8, i8* %23
%112 = call i32 @sprintf(i8* %22, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %111)
%113 = load i8, i8* %25
%114 = call i32 @sprintf(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %113)
%115 = load i8, i8* %27
%116 = call i32 @sprintf(i8* %26, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %115)
%117 = load i8, i8* %29
%118 = call i32 @sprintf(i8* %28, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %117)
%119 = load i8, i8* %31
%120 = call i32 @sprintf(i8* %30, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %119)
%121 = load i8, i8* %33
%122 = call i32 @sprintf(i8* %32, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %121)
%123 = load i8, i8* %35
%124 = call i32 @sprintf(i8* %34, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %123)
%125 = load i8, i8* %37
%126 = call i32 @sprintf(i8* %36, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %125)
%127 = load i8, i8* %39
%128 = call i32 @sprintf(i8* %38, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %127)
%129 = load i8, i8* %41
%130 = call i32 @sprintf(i8* %40, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %129)
%131 = load i8, i8* %43
%132 = call i32 @sprintf(i8* %42, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %131)
%133 = load i8, i8* %45
%134 = call i32 @sprintf(i8* %44, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %133)
%135 = load i8, i8* %47
%136 = call i32 @sprintf(i8* %46, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %135)
%137 = load i8, i8* %49
%138 = call i32 @sprintf(i8* %48, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %137)
%139 = load i8, i8* %51
%140 = call i32 @sprintf(i8* %50, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %139)
%141 = load i8, i8* %53
%142 = call i32 @sprintf(i8* %52, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %141)
%143 = load i8, i8* %55
%144 = call i32 @sprintf(i8* %54, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %143)
%145 = load i8, i8* %57
%146 = call i32 @sprintf(i8* %56, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %145)
%147 = add nsw i32 %64, 1
%148 = call i64 @memcmp(i8* %7, i8* %6, i32 40)
%149 = icmp eq i64 %148, 0
br i1 %149, label %154, label %150
150: ; preds = %106
%151 = add nsw i32 %66, 1
%152 = load i32, i32* @stderr
%153 = call i32 @fprintf(i32 %152, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %19)
br label %154
154: ; preds = %150, %106
%155 = phi i32 [ %151, %150 ], [ %66, %106 ]
%156 = call i32* @fgets(i8* %7, i64 1023, i32* %8)
%157 = icmp eq i32* %156, null
br i1 %157, label %158, label %63
158: ; preds = %154, %70
%159 = phi i32 [ %66, %70 ], [ %155, %154 ]
%160 = phi i32 [ %65, %70 ], [ %98, %154 ]
%161 = phi i32 [ %64, %70 ], [ %147, %154 ]
%162 = icmp eq i32 %62, 0
br i1 %162, label %169, label %163
163: ; preds = %101, %158
%164 = phi i32 [ %161, %158 ], [ %64, %101 ]
%165 = phi i32 [ %160, %158 ], [ %98, %101 ]
%166 = phi i32 [ %159, %158 ], [ %66, %101 ]
%167 = phi i32 [ %62, %158 ], [ %102, %101 ]
%168 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %167, i32 %165)
br label %169
169: ; preds = %163, %158
%170 = phi i1 [ true, %163 ], [ false, %158 ]
%171 = phi i32 [ %164, %163 ], [ %161, %158 ]
%172 = phi i32 [ %166, %163 ], [ %159, %158 ]
%173 = icmp eq i32 %172, 0
br i1 %173, label %176, label %174
174: ; preds = %169
%175 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i32 %172, i32 %171)
br label %176
176: ; preds = %12, %174, %169
%177 = phi i1 [ true, %174 ], [ false, %169 ], [ false, %12 ]
%178 = phi i1 [ %170, %174 ], [ %170, %169 ], [ false, %12 ]
%179 = or i1 %178, %177
%180 = zext i1 %179 to i32
br label %181
181: ; preds = %176, %10
%182 = phi i32 [ 1, %10 ], [ %180, %176 ]
ret i32 %182
}