#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
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];
  char diff;
  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, (int)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]);
    diff = 0;
    for (i = 0; i < 40; i++)
      diff |= line[i] ^ buf[i];
    if (diff != 0) {
      nb_err2++;
      fprintf(stderr, "wrong checksum: %s\n", line + 42);
    }
    n = sizeof(line);
  }
  fclose(f);
  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   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1461 <sha1_check+0x2d1>
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   1070 <memset@plt>
movq   $0x400,-0x20(%rbp)
lea    -0x480(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    %eax,%esi
sub    $0x1,%esi
mov    -0x28(%rbp),%rdx
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     13ef <sha1_check+0x25f>
lea    -0x480(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x2c,-0x20(%rbp)
jae    1255 <sha1_check+0xc5>
jmp    1212 <sha1_check+0x82>
movsbl -0x458(%rbp),%eax
cmp    $0x20,%eax
jne    1275 <sha1_check+0xe5>
movsbl -0x457(%rbp),%eax
cmp    $0x20,%eax
je     127a <sha1_check+0xea>
jmp    1212 <sha1_check+0x82>
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
movsbl -0x480(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    12ab <sha1_check+0x11b>
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    12dc <sha1_check+0x14c>
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     1311 <sha1_check+0x181>
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    135d <sha1_check+0x1cd>
lea    -0x80(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
movslq -0x14(%rbp),%rax
lea    0xcd2(%rip),%rsi
movzbl -0x50(%rbp,%rax,1),%edx
call   10b0 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1321 <sha1_check+0x191>
movb   $0x0,-0x481(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x28,-0x14(%rbp)
jge    13a9 <sha1_check+0x219>
movslq -0x14(%rbp),%rax
movsbl -0x480(%rbp,%rax,1),%ecx
ff
movslq -0x14(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
xor    %eax,%ecx
movsbl -0x481(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x481(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    136b <sha1_check+0x1db>
movsbl -0x481(%rbp),%eax
cmp    $0x0,%eax
je     13e2 <sha1_check+0x252>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    0x2c17(%rip),%rax
mov    (%rax),%edi
lea    -0x480(%rbp),%rdx
add    $0x2a,%rdx
lea    0xc3f(%rip),%rsi
call   1090 <fprintf@plt>
movq   $0x400,-0x20(%rbp)
jmp    1212 <sha1_check+0x82>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x2c(%rbp)
je     1416 <sha1_check+0x286>
mov    -0x2c(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xc21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x30(%rbp)
je     1434 <sha1_check+0x2a4>
mov    -0x30(%rbp),%esi
mov    -0x38(%rbp),%edx
lea    0xc3a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x482(%rbp)
jne    1453 <sha1_check+0x2c3>
cmpl   $0x0,-0x30(%rbp)
setne  %al
mov    %al,-0x482(%rbp)
mov    -0x482(%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    $0x458,%rsp
mov    %rdi,%rbp
lea    0xe65(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1514 <sha1_check+0x384>
mov    %rax,%rbx
lea    0x50(%rsp),%rbp
xor    %r14d,%r14d
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    %rbp,%rdi
mov    $0x3ff,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     152c <sha1_check+0x39c>
lea    0x50(%rsp),%r13
lea    0xe2f(%rip),%r12
xor    %r15d,%r15d
xor    %ebp,%ebp
movl   $0x0,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    $0x2b,%rax
jbe    122c <sha1_check+0x9c>
cmpb   $0x20,0x78(%rsp)
jne    122c <sha1_check+0x9c>
cmpb   $0x20,0x79(%rsp)
je     1244 <sha1_check+0xb4>
lea    -0x1(%rax),%esi
mov    %r13,%rdi
mov    %rbx,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    1210 <sha1_check+0x80>
jmp    14d6 <sha1_check+0x346>
mov    %r14d,0x1c(%rsp)
lea    -0x1(%rax),%r14
movzbl 0x4f(%rsp,%rax,1),%edx
cmp    $0xa,%dl
jne    126f <sha1_check+0xdf>
movb   $0x0,0x4f(%rsp,%rax,1)
mov    %rax,%rcx
add    $0xfffffffffffffffe,%rcx
movzbl 0x4e(%rsp,%rax,1),%edx
cmp    $0xd,%dl
je     127a <sha1_check+0xea>
jmp    1282 <sha1_check+0xf2>
mov    %r14,%rcx
mov    %rax,%r14
cmp    $0xd,%dl
jne    1282 <sha1_check+0xf2>
movb   $0x0,0x50(%rsp,%rcx,1)
mov    %rcx,%r14
add    $0x1,%r15d
lea    0x7a(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <sha1_wrapper@plt>
test   %rax,%rax
jne    14a3 <sha1_check+0x313>
movzbl (%rsp),%edx
lea    0x20(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x1(%rsp),%edx
lea    0x22(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x2(%rsp),%edx
lea    0x24(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x3(%rsp),%edx
lea    0x26(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x4(%rsp),%edx
lea    0x28(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x5(%rsp),%edx
lea    0x2a(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x6(%rsp),%edx
lea    0x2c(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x7(%rsp),%edx
lea    0x2e(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x8(%rsp),%edx
lea    0x30(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x9(%rsp),%edx
lea    0x32(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0xa(%rsp),%edx
lea    0x34(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0xb(%rsp),%edx
lea    0x36(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0xc(%rsp),%edx
lea    0x38(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0xd(%rsp),%edx
lea    0x3a(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0xe(%rsp),%edx
lea    0x3c(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0xf(%rsp),%edx
lea    0x3e(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x10(%rsp),%edx
lea    0x40(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x11(%rsp),%edx
lea    0x42(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x12(%rsp),%edx
lea    0x44(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movzbl 0x13(%rsp),%edx
lea    0x46(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <sprintf@plt>
movdqa 0x30(%rsp),%xmm0
pxor   0x60(%rsp),%xmm0
movdqa 0x20(%rsp),%xmm1
pxor   0x50(%rsp),%xmm1
por    %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
por    %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
por    %xmm0,%xmm1
movdqa %xmm1,%xmm0
psrld  $0x10,%xmm0
por    %xmm1,%xmm0
movdqa %xmm0,%xmm1
psrlw  $0x8,%xmm1
por    %xmm0,%xmm1
pand   0xbad(%rip),%xmm1
mov    0x40(%rsp),%rax
xor    0x70(%rsp),%rax
movq   %rax,%xmm0
por    %xmm1,%xmm0
movq   %xmm0,%rax
test   %rax,%rax
mov    0x1c(%rsp),%r14d
je     1492 <sha1_check+0x302>
add    $0x1,%ebp
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
lea    0xba4(%rip),%rsi
lea    0x7a(%rsp),%rdx
call   1090 <fprintf@plt>
add    $0x1,%r14d
mov    %r13,%rdi
mov    $0x3ff,%esi
jmp    1232 <sha1_check+0xa2>
addl   $0x1,0x18(%rsp)
add    $0xffffffff,%r14d
mov    %r13,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
mov    0x1c(%rsp),%r14d
jne    1210 <sha1_check+0x80>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x18(%rsp),%esi
jmp    14e6 <sha1_check+0x356>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x18(%rsp),%esi
test   %esi,%esi
je     153a <sha1_check+0x3aa>
lea    0xb53(%rip),%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%bl
test   %ebp,%ebp
je     1540 <sha1_check+0x3b0>
lea    0xb73(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%al
jmp    1542 <sha1_check+0x3b2>
lea    0xaf8(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%eax
jmp    1547 <sha1_check+0x3b7>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
xor    %ebx,%ebx
jmp    1542 <sha1_check+0x3b2>
xor    %ebx,%ebx
test   %ebp,%ebp
jne    14fd <sha1_check+0x36d>
xor    %eax,%eax
or     %bl,%al
movzbl %al,%eax
add    $0x458,%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]
%14 = alloca i8
store i8* %0, i8** %3
%15 = load i8*, i8** %3
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %1
%19 = load i8*, i8** %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %19)
store i32 1, i32* %2
br label %164
21: ; preds = %1
store i32 0, i32* %8
store i32 0, i32* %7
store i32 0, i32* %10
store i32 0, i32* %9
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%23 = call i32 @memset(i8* %22, i32 0, i32 1024)
store i64 1024, i64* %5
br label %24
24: ; preds = %138, %81, %48, %37, %21
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%26 = load i64, i64* %5
%27 = trunc i64 %26 to i32
%28 = sub nsw i32 %27, 1
%29 = load i32*, i32** %6
%30 = call i32* @fgets(i8* %25, i32 %28, i32* %29)
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %139
32: ; preds = %24
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%34 = call i64 @strlen(i8* %33)
store i64 %34, i64* %5
%35 = load i64, i64* %5
%36 = icmp ult i64 %35, 44
br i1 %36, label %37, label %38
37: ; preds = %32
br label %24
38: ; preds = %32
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 40
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 32
br i1 %42, label %48, label %43
43: ; preds = %38
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 41
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 32
br i1 %47, label %48, label %49
48: ; preds = %43, %38
br label %24
49: ; preds = %43
%50 = load i64, i64* %5
%51 = sub i64 %50, 1
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 10
br i1 %55, label %56, label %61
56: ; preds = %49
%57 = load i64, i64* %5
%58 = add i64 %57, -1
store i64 %58, i64* %5
%59 = load i64, i64* %5
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %59
store i8 0, i8* %60
br label %61
61: ; preds = %56, %49
%62 = load i64, i64* %5
%63 = sub i64 %62, 1
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 13
br i1 %67, label %68, label %73
68: ; preds = %61
%69 = load i64, i64* %5
%70 = add i64 %69, -1
store i64 %70, i64* %5
%71 = load i64, i64* %5
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %71
store i8 0, i8* %72
br label %73
73: ; preds = %68, %61
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%77 = getelementptr inbounds i8, i8* %76, i64 42
%78 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%79 = call i64 @sha1_wrapper(i8* %77, i8* %78)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %73
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
store i32 %83, i32* %7
br label %24
84: ; preds = %73
%85 = load i32, i32* %10
%86 = add nsw i32 %85, 1
store i32 %86, i32* %10
store i32 0, i32* %4
br label %87
87: ; preds = %101, %84
%88 = load i32, i32* %4
%89 = icmp slt i32 %88, 20
br i1 %89, label %90, label %104
90: ; preds = %87
%91 = getelementptr inbounds [41 x i8], [41 x i8]* %12, i64 0, i64 0
%92 = load i32, i32* %4
%93 = mul nsw i32 %92, 2
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %91, i64 %94
%96 = load i32, i32* %4
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %97
%99 = load i8, i8* %98
%100 = call i32 @sprintf(i8* %95, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %99)
br label %101
101: ; preds = %90
%102 = load i32, i32* %4
%103 = add nsw i32 %102, 1
store i32 %103, i32* %4
br label %87
104: ; preds = %87
store i8 0, i8* %14
store i32 0, i32* %4
br label %105
105: ; preds = %124, %104
%106 = load i32, i32* %4
%107 = icmp slt i32 %106, 40
br i1 %107, label %108, label %127
108: ; preds = %105
%109 = load i32, i32* %4
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %110
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = load i32, i32* %4
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [41 x i8], [41 x i8]* %12, i64 0, i64 %115
%117 = load i8, i8* %116
%118 = sext i8 %117 to i32
%119 = xor i32 %113, %118
%120 = load i8, i8* %14
%121 = sext i8 %120 to i32
%122 = or i32 %121, %119
%123 = trunc i32 %122 to i8
store i8 %123, i8* %14
br label %124
124: ; preds = %108
%125 = load i32, i32* %4
%126 = add nsw i32 %125, 1
store i32 %126, i32* %4
br label %105
127: ; preds = %105
%128 = load i8, i8* %14
%129 = sext i8 %128 to i32
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %138
131: ; preds = %127
%132 = load i32, i32* %8
%133 = add nsw i32 %132, 1
store i32 %133, i32* %8
%134 = load i32, i32* @stderr
%135 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%136 = getelementptr inbounds i8, i8* %135, i64 42
%137 = call i32 @fprintf(i32 %134, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %136)
br label %138
138: ; preds = %131, %127
store i64 1024, i64* %5
br label %24
139: ; preds = %24
%140 = load i32*, i32** %6
%141 = call i32 @fclose(i32* %140)
%142 = load i32, i32* %7
%143 = icmp ne i32 %142, 0
br i1 %143, label %144, label %148
144: ; preds = %139
%145 = load i32, i32* %7
%146 = load i32, i32* %9
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %145, i32 %146)
br label %148
148: ; preds = %144, %139
%149 = load i32, i32* %8
%150 = icmp ne i32 %149, 0
br i1 %150, label %151, label %155
151: ; preds = %148
%152 = load i32, i32* %8
%153 = load i32, i32* %10
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i32 %152, i32 %153)
br label %155
155: ; preds = %151, %148
%156 = load i32, i32* %7
%157 = icmp ne i32 %156, 0
br i1 %157, label %161, label %158
158: ; preds = %155
%159 = load i32, i32* %8
%160 = icmp ne i32 %159, 0
br label %161
161: ; preds = %158, %155
%162 = phi i1 [ true, %155 ], [ %160, %158 ]
%163 = zext i1 %162 to i32
store i32 %163, i32* %2
br label %164
164: ; preds = %161, %18
%165 = load i32, i32* %2
ret i32 %165
}

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 %211
12: ; preds = %1
%13 = call i32 @memset(i8* %7, i32 0, i32 1024)
%14 = call i32* @fgets(i8* %7, i32 1023, i32* %8)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @fclose(i32* %8)
br label %206
18: ; preds = %12
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 40
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 41
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 42
%22 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 2
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 1
%24 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 4
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 2
%26 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 6
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 3
%28 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 8
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 4
%30 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 10
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 5
%32 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 12
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 6
%34 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 14
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 7
%36 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 16
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 8
%38 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 18
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 9
%40 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 20
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 10
%42 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 22
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 11
%44 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 24
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 12
%46 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 26
%47 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 13
%48 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 28
%49 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 14
%50 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 30
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 15
%52 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 32
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 16
%54 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 34
%55 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 17
%56 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 36
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 18
%58 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 38
%59 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 19
%60 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 16
%61 = bitcast i8* %60 to <16 x i8>*
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 16
%63 = bitcast i8* %62 to <16 x i8>*
%64 = bitcast [41 x i8]* %3 to <16 x i8>*
%65 = bitcast [1024 x i8]* %4 to <16 x i8>*
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 32
%67 = bitcast i8* %66 to <8 x i8>*
%68 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 32
%69 = bitcast i8* %68 to <8 x i8>*
br label %70
70: ; preds = %18, %114
%71 = phi i32 [ 0, %18 ], [ %76, %114 ]
%72 = phi i32 [ 0, %18 ], [ %111, %114 ]
%73 = phi i32 [ 0, %18 ], [ %78, %114 ]
%74 = phi i32 [ 0, %18 ], [ %115, %114 ]
br label %75
75: ; preds = %70, %183
%76 = phi i32 [ %71, %70 ], [ %177, %183 ]
%77 = phi i32 [ %72, %70 ], [ %111, %183 ]
%78 = phi i32 [ %73, %70 ], [ %184, %183 ]
br label %79
79: ; preds = %75, %82
%80 = call i64 @strlen(i8* %7)
%81 = icmp ult i64 %80, 44
br i1 %81, label %82, label %87
82: ; preds = %79, %87
%83 = trunc i64 %80 to i32
%84 = add nsw i32 %83, -1
%85 = call i32* @fgets(i8* %7, i32 %84, i32* %8)
%86 = icmp eq i32* %85, null
br i1 %86, label %187, label %79
87: ; preds = %79
%88 = load i8, i8* %19
%89 = icmp ne i8 %88, 32
%90 = load i8, i8* %20
%91 = icmp ne i8 %90, 32
%92 = select i1 %89, i1 true, i1 %91
br i1 %92, label %82, label %93
93: ; preds = %87
%94 = add i64 %80, -1
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %94
%96 = load i8, i8* %95
%97 = icmp eq i8 %96, 10
br i1 %97, label %98, label %102
98: ; preds = %93
store i8 0, i8* %95
%99 = add i64 %80, -2
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %99
%101 = load i8, i8* %100
br label %102
102: ; preds = %98, %93
%103 = phi i8 [ %101, %98 ], [ %96, %93 ]
%104 = phi i64 [ %99, %98 ], [ %94, %93 ]
%105 = phi i64 [ %94, %98 ], [ %80, %93 ]
%106 = icmp eq i8 %103, 13
br i1 %106, label %107, label %109
107: ; preds = %102
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %104
store i8 0, i8* %108
br label %109
109: ; preds = %107, %102
%110 = phi i64 [ %104, %107 ], [ %105, %102 ]
%111 = add nsw i32 %77, 1
%112 = call i64 @sha1_wrapper(i8* %21, i8* %5)
%113 = icmp eq i64 %112, 0
br i1 %113, label %122, label %114
114: ; preds = %109
%115 = add nuw nsw i32 %74, 1
%116 = trunc i64 %110 to i32
%117 = add nsw i32 %116, -1
%118 = call i32* @fgets(i8* %7, i32 %117, i32* %8)
%119 = icmp eq i32* %118, null
br i1 %119, label %120, label %70
120: ; preds = %114
%121 = call i32 @fclose(i32* %8)
br label %193
122: ; preds = %109
%123 = load i8, i8* %5
%124 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %123)
%125 = load i8, i8* %23
%126 = call i32 @sprintf(i8* %22, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %125)
%127 = load i8, i8* %25
%128 = call i32 @sprintf(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %127)
%129 = load i8, i8* %27
%130 = call i32 @sprintf(i8* %26, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %129)
%131 = load i8, i8* %29
%132 = call i32 @sprintf(i8* %28, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %131)
%133 = load i8, i8* %31
%134 = call i32 @sprintf(i8* %30, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %133)
%135 = load i8, i8* %33
%136 = call i32 @sprintf(i8* %32, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %135)
%137 = load i8, i8* %35
%138 = call i32 @sprintf(i8* %34, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %137)
%139 = load i8, i8* %37
%140 = call i32 @sprintf(i8* %36, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %139)
%141 = load i8, i8* %39
%142 = call i32 @sprintf(i8* %38, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %141)
%143 = load i8, i8* %41
%144 = call i32 @sprintf(i8* %40, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %143)
%145 = load i8, i8* %43
%146 = call i32 @sprintf(i8* %42, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %145)
%147 = load i8, i8* %45
%148 = call i32 @sprintf(i8* %44, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %147)
%149 = load i8, i8* %47
%150 = call i32 @sprintf(i8* %46, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %149)
%151 = load i8, i8* %49
%152 = call i32 @sprintf(i8* %48, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %151)
%153 = load i8, i8* %51
%154 = call i32 @sprintf(i8* %50, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %153)
%155 = load i8, i8* %53
%156 = call i32 @sprintf(i8* %52, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %155)
%157 = load i8, i8* %55
%158 = call i32 @sprintf(i8* %54, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %157)
%159 = load i8, i8* %57
%160 = call i32 @sprintf(i8* %56, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %159)
%161 = load i8, i8* %59
%162 = call i32 @sprintf(i8* %58, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %161)
%163 = load <16 x i8>, <16 x i8>* %61
%164 = load <16 x i8>, <16 x i8>* %63
%165 = xor <16 x i8> %163, %164
%166 = load <16 x i8>, <16 x i8>* %64
%167 = load <16 x i8>, <16 x i8>* %65
%168 = xor <16 x i8> %166, %167
%169 = or <16 x i8> %165, %168
%170 = call i8 @llvm.vector.reduce.or.v16i8(<16 x i8> %169)
%171 = insertelement <8 x i8> <i8 poison, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>, i8 %170, i64 0
%172 = load <8 x i8>, <8 x i8>* %67
%173 = load <8 x i8>, <8 x i8>* %69
%174 = xor <8 x i8> %173, %172
%175 = or <8 x i8> %174, %171
%176 = call i8 @llvm.vector.reduce.or.v8i8(<8 x i8> %175)
%177 = add nsw i32 %76, 1
%178 = icmp eq i8 %176, 0
br i1 %178, label %183, label %179
179: ; preds = %122
%180 = add nsw i32 %78, 1
%181 = load i32, i32* @stderr
%182 = call i32 @fprintf(i32 %181, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %183
183: ; preds = %179, %122
%184 = phi i32 [ %180, %179 ], [ %78, %122 ]
%185 = call i32* @fgets(i8* %7, i32 1023, i32* %8)
%186 = icmp eq i32* %185, null
br i1 %186, label %187, label %75
187: ; preds = %183, %82
%188 = phi i32 [ %78, %82 ], [ %184, %183 ]
%189 = phi i32 [ %77, %82 ], [ %111, %183 ]
%190 = phi i32 [ %76, %82 ], [ %177, %183 ]
%191 = call i32 @fclose(i32* %8)
%192 = icmp eq i32 %74, 0
br i1 %192, label %199, label %193
193: ; preds = %120, %187
%194 = phi i32 [ %76, %120 ], [ %190, %187 ]
%195 = phi i32 [ %111, %120 ], [ %189, %187 ]
%196 = phi i32 [ %78, %120 ], [ %188, %187 ]
%197 = phi i32 [ %115, %120 ], [ %74, %187 ]
%198 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %197, i32 %195)
br label %199
199: ; preds = %193, %187
%200 = phi i1 [ true, %193 ], [ false, %187 ]
%201 = phi i32 [ %194, %193 ], [ %190, %187 ]
%202 = phi i32 [ %196, %193 ], [ %188, %187 ]
%203 = icmp eq i32 %202, 0
br i1 %203, label %206, label %204
204: ; preds = %199
%205 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i32 %202, i32 %201)
br label %206
206: ; preds = %16, %204, %199
%207 = phi i1 [ false, %16 ], [ true, %204 ], [ false, %199 ]
%208 = phi i1 [ false, %16 ], [ %200, %204 ], [ %200, %199 ]
%209 = or i1 %208, %207
%210 = zext i1 %209 to i32
br label %211
211: ; preds = %206, %10
%212 = phi i32 [ 1, %10 ], [ %210, %206 ]
ret i32 %212
}