#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 option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ sha1;
typedef int /*<<< orphan*/ SHA_CTX;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SHA1_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA1_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA1_Update(int /*<<< orphan*/ *, char *, int);
int SHA_DIGEST_LENGTH;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int getopt_long(int, char **, char *, struct option *, int *);
#define no_argument 128
int open(char *, int /*<<< orphan*/);
int optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ sha1hash_usage();
int /*<<< orphan*/ sha1hash_version();
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int c;
  int x;
  int y;
  int fd;
  int quiet;
  int verbose;
  int opt_index;
  char data[512];
  ssize_t data_len;
  SHA_CTX sha1;
  unsigned char buff[SHA_DIGEST_LENGTH];
  static char short_opt[] = "hqVv";
  static struct option long_opt[] = {
      {"help", no_argument, 0, 'h'},    {"silent", no_argument, 0, 'q'},
      {"quiet", no_argument, 0, 'q'},   {"verbose", no_argument, 0, 'v'},
      {"version", no_argument, 0, 'V'}, {NULL, 0, 0, 0}};
  quiet = 0;
  verbose = 0;
  while ((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) {
    switch (c) {
    case -1:
    case 0:
      break;
    case 'h':
      sha1hash_usage();
      return (0);
    case 'q':
      quiet++;
      break;
    case 'V':
      sha1hash_version();
      return (0);
    case 'v':
      verbose++;
      break;
    case '?':
      fprintf(stderr, "Try `%s --help' for more information.\n", "sha1hash");
      return (1);
    default:
      fprintf(stderr, "%s: unrecognized option `--%c'\n", "sha1hash", c);
      fprintf(stderr, "Try `%s --help' for more information.\n", "sha1hash");
      return (1);
    };
  };
  if (optind >= argc) {
    fprintf(stderr, "%s: missing required argument\n", "sha1hash");
    fprintf(stderr, "Try `%s --help' for more information.\n", "sha1hash");
    return (1);
  };
  for (x = optind; x < argc; x++) {
    if (verbose)
      printf("opening \"%s\"...\n", argv[x]);
    if ((fd = open(argv[x], O_RDONLY)) == -1) {
      if (!(quiet))
        perror("open()");
      return (1);
    };
    if (verbose)
      printf("generating hash for \"%s\"...\n", argv[x]);
    SHA1_Init(&sha1);
    printf("sizeof(sha1) == %lu\n", sizeof(sha1));
    while ((data_len = read(fd, data, 512)) > 0)
      SHA1_Update(&sha1, data, data_len);
    if (data_len == -1) {
      if (!(quiet))
        perror("open()");
      return (1);
    };
    SHA1_Final(buff, &sha1);
    if (verbose)
      printf("displaying hash for \"%s\"...\n", argv[x]);
    for (y = 0; y < SHA_DIGEST_LENGTH; y++)
      printf("%02x", buff[y]);
    printf("  %s\n", argv[x]);
    if (verbose)
      printf("closing \"%s\"...\n", argv[x]);
    close(fd);
  };
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x240(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x258(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x248(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0x2e66(%rip),%rdx
lea    0x2e6f(%rip),%rcx
lea    -0x2c(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     13ad <main+0x1ed>
mov    -0x14(%rbp),%eax
mov    %eax,-0x25c(%rbp)
add    $0x1,%eax
sub    $0x2,%eax
jb     12c4 <main+0x104>
jmp    1260 <main+0xa0>
mov    -0x25c(%rbp),%eax
sub    $0x3f,%eax
je     131f <main+0x15f>
jmp    1274 <main+0xb4>
mov    -0x25c(%rbp),%eax
sub    $0x56,%eax
je     12f4 <main+0x134>
jmp    1288 <main+0xc8>
mov    -0x25c(%rbp),%eax
sub    $0x68,%eax
je     12c9 <main+0x109>
jmp    129c <main+0xdc>
mov    -0x25c(%rbp),%eax
sub    $0x71,%eax
je     12e6 <main+0x126>
jmp    12b0 <main+0xf0>
mov    -0x25c(%rbp),%eax
sub    $0x76,%eax
je     1311 <main+0x151>
jmp    1353 <main+0x193>
jmp    13a8 <main+0x1e8>
mov    $0x0,%al
call   10a0 <sha1hash_usage@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24c(%rbp)
jmp    163c <main+0x47c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    13a8 <main+0x1e8>
mov    $0x0,%al
call   1070 <sha1hash_version@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24c(%rbp)
jmp    163c <main+0x47c>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    13a8 <main+0x1e8>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
lea    0xcf3(%rip),%rsi
lea    0xd13(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x24c(%rbp)
jmp    163c <main+0x47c>
mov    0x2c6e(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%ecx
lea    0xcec(%rip),%rsi
lea    0xcdc(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c4d(%rip),%rax
mov    (%rax),%edi
lea    0xc9e(%rip),%rsi
lea    0xcbe(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x24c(%rbp)
jmp    163c <main+0x47c>
jmp    121c <main+0x5c>
mov    0x2c24(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     1411 <main+0x251>
mov    0x2c02(%rip),%rax
mov    (%rax),%edi
lea    0xca3(%rip),%rsi
lea    0xc73(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2be4(%rip),%rax
mov    (%rax),%edi
lea    0xc35(%rip),%rsi
lea    0xc55(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x24c(%rbp)
jmp    163c <main+0x47c>
mov    0x2bc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    162b <main+0x46b>
cmpl   $0x0,-0x28(%rbp)
je     144d <main+0x28d>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xc4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2b88(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    149f <main+0x2df>
cmpl   $0x0,-0x24(%rbp)
jne    1489 <main+0x2c9>
lea    0xc1e(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x24c(%rbp)
jmp    163c <main+0x47c>
cmpl   $0x0,-0x28(%rbp)
je     14c3 <main+0x303>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xbed(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x238(%rbp),%rdi
call   10b0 <SHA1_Init@plt>
lea    0xbf0(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x230(%rbp),%rsi
mov    $0x200,%edx
call   1060 <read@plt>
mov    %eax,-0x234(%rbp)
cmp    $0x0,%eax
jle    1523 <main+0x363>
lea    -0x230(%rbp),%rsi
mov    -0x234(%rbp),%edx
lea    -0x238(%rbp),%rdi
call   1090 <SHA1_Update@plt>
jmp    14e2 <main+0x322>
cmpl   $0xffffffff,-0x234(%rbp)
jne    155c <main+0x39c>
cmpl   $0x0,-0x24(%rbp)
jne    1546 <main+0x386>
lea    0xb61(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x24c(%rbp)
jmp    163c <main+0x47c>
mov    -0x258(%rbp),%rdi
lea    -0x238(%rbp),%rsi
call   10e0 <SHA1_Final@plt>
cmpl   $0x0,-0x28(%rbp)
je     1593 <main+0x3d3>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xb4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2a3c(%rip),%rcx
cmp    (%rcx),%eax
jge    15d7 <main+0x417>
mov    -0x258(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xb36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    159a <main+0x3da>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xb13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x28(%rbp)
je     1615 <main+0x455>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xaf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1050 <close@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    141d <main+0x25d>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24c(%rbp)
mov    -0x240(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x248,%rsp
mov    %rsi,-0x50(%rbp)
mov    %rsp,-0x60(%rbp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
movl   $0x0,-0x2c(%rbp)
lea    0x2e88(%rip),%r14
lea    0x2e91(%rip),%r12
lea    -0x64(%rbp),%r13
lea    0xde6(%rip),%rbx
movl   $0x0,-0x30(%rbp)
mov    %edi,-0x34(%rbp)
mov    -0x50(%rbp),%r15
nopl   0x0(%rax,%rax,1)
mov    -0x34(%rbp),%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <getopt_long@plt>
mov    -0x34(%rbp),%edi
test   %eax,%eax
je     1230 <main+0x70>
lea    -0x56(%rax),%ecx
cmp    $0x20,%ecx
ja     1268 <main+0xa8>
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
addl   $0x1,-0x2c(%rbp)
jmp    1230 <main+0x70>
addl   $0x1,-0x30(%rbp)
jmp    1230 <main+0x70>
cmp    $0xffffffff,%eax
je     12d4 <main+0x114>
cmp    $0x3f,%eax
jne    128e <main+0xce>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
lea    0xe44(%rip),%rdx
jmp    14b7 <main+0x2f7>
mov    0x2d33(%rip),%rbx
mov    (%rbx),%edi
lea    0xe38(%rip),%rsi
lea    0xe28(%rip),%r14
mov    %r14,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    14ab <main+0x2eb>
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <sha1hash_version@plt>
jmp    14c4 <main+0x304>
xor    %r14d,%r14d
xor    %eax,%eax
call   10a0 <sha1hash_usage@plt>
jmp    14c4 <main+0x304>
mov    0x2cfd(%rip),%rax
movslq (%rax),%rax
cmp    %edi,%eax
jge    148a <main+0x2ca>
mov    %rax,-0x40(%rbp)
lea    -0x270(%rbp),%r15
mov    -0x50(%rbp),%r12
mov    -0x30(%rbp),%r13d
jmp    1323 <main+0x163>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1050 <close@plt>
add    $0x1,%r15
xor    %r14d,%r14d
mov    %r15,-0x40(%rbp)
cmp    -0x34(%rbp),%r15d
lea    -0x270(%rbp),%r15
je     14c4 <main+0x304>
test   %r13d,%r13d
mov    -0x40(%rbp),%r14
je     133e <main+0x17e>
mov    (%r12,%r14,8),%rsi
lea    0xdde(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12,%r14,8),%rdi
mov    0x2c9f(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     14da <main+0x31a>
mov    %eax,%ebx
test   %r13d,%r13d
je     1376 <main+0x1b6>
mov    -0x40(%rbp),%rax
mov    (%r12,%rax,8),%rsi
lea    0xdbe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%r14d
lea    -0x44(%rbp),%rdi
call   10b0 <SHA1_Init@plt>
mov    $0x4,%esi
lea    0xdbc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x200,%edx
call   1060 <read@plt>
lea    -0x44(%rbp),%r15
test   %eax,%eax
jle    13e0 <main+0x220>
lea    -0x270(%rbp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1090 <SHA1_Update@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x200,%edx
call   1060 <read@plt>
test   %eax,%eax
jg     13c0 <main+0x200>
cmp    $0xffffffff,%eax
je     14da <main+0x31a>
mov    -0x58(%rbp),%rdi
mov    %r15,%rsi
call   10e0 <SHA1_Final@plt>
test   %r14d,%r14d
je     1410 <main+0x250>
mov    -0x40(%rbp),%rax
mov    (%r12,%rax,8),%rsi
lea    0xd56(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2bc9(%rip),%r15
cmpl   $0x0,(%r15)
mov    -0x58(%rbp),%r13
lea    0xd56(%rip),%r14
jle    144c <main+0x28c>
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%r13,%r12,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
movslq (%r15),%rax
cmp    %rax,%r12
jl     1430 <main+0x270>
mov    -0x50(%rbp),%r12
mov    -0x40(%rbp),%r15
mov    (%r12,%r15,8),%rsi
lea    0xd22(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x30(%rbp),%r13d
test   %r13d,%r13d
je     1300 <main+0x140>
mov    (%r12,%r15,8),%rsi
lea    0xd09(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1300 <main+0x140>
mov    0x2b37(%rip),%rbx
mov    (%rbx),%edi
lea    0xc5c(%rip),%rsi
lea    0xc2c(%rip),%r14
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xbf2(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%r14d
mov    -0x60(%rbp),%rsp
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r14d
cmpl   $0x0,-0x2c(%rbp)
jne    14c4 <main+0x304>
lea    0xc39(%rip),%rdi
call   10d0 <perror@plt>
jmp    14c4 <main+0x304>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@SHA_DIGEST_LENGTH = global i32 0
@main.short_opt = internal global [5 x i8] c"hqVv\00"
@main.long_opt = internal global [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 113 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 113 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 118 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8 -128, i32 0, i32 86 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [7 x i8] c"silent\00"
@.str.2 = [6 x i8] c"quiet\00"
@.str.3 = [8 x i8] c"verbose\00"
@.str.4 = [8 x i8] c"version\00"
@stderr = global i32 0
@.str.5 = [39 x i8] c"Try `%s --help' for more information.\0A\00"
@.str.6 = [9 x i8] c"sha1hash\00"
@.str.7 = [32 x i8] c"%s: unrecognized option `--%c'\0A\00"
@optind = global i32 0
@.str.8 = [31 x i8] c"%s: missing required argument\0A\00"
@.str.9 = [17 x i8] c"opening \22%s\22...\0A\00"
@O_RDONLY = global i32 0
@.str.10 = [7 x i8] c"open()\00"
@.str.11 = [29 x i8] c"generating hash for \22%s\22...\0A\00"
@.str.12 = [21 x i8] c"sizeof(sha1) == %lu\0A\00"
@.str.13 = [29 x i8] c"displaying hash for \22%s\22...\0A\00"
@.str.14 = [5 x i8] c"%02x\00"
@.str.15 = [6 x i8] c" %s\0A\00"
@.str.16 = [17 x i8] c"closing \22%s\22...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [512 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* @SHA_DIGEST_LENGTH
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %16
%22 = alloca i8, i64 %20
store i64 %20, i64* %17
store i32 0, i32* %10
store i32 0, i32* %11
br label %23
23: ; preds = %50, %2
%24 = load i32, i32* %4
%25 = load i8**, i8*** %5
%26 = call i32 @getopt_long(i32 %24, i8** %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @main.short_opt, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.long_opt, i64 0, i64 0), i32* %12)
store i32 %26, i32* %6
%27 = icmp ne i32 %26, -1
br i1 %27, label %28, label %51
28: ; preds = %23
%29 = load i32, i32* %6
switch i32 %29, label %44 [
i32 -1, label %30
i32 0, label %30
i32 104, label %31
i32 113, label %33
i32 86, label %36
i32 118, label %38
i32 63, label %41
]
30: ; preds = %28, %28
br label %50
31: ; preds = %28
%32 = call i32 (...) @sha1hash_usage()
store i32 0, i32* %3
store i32 1, i32* %18
br label %171
33: ; preds = %28
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %50
36: ; preds = %28
%37 = call i32 (...) @sha1hash_version()
store i32 0, i32* %3
store i32 1, i32* %18
br label %171
38: ; preds = %28
%39 = load i32, i32* %11
%40 = add nsw i32 %39, 1
store i32 %40, i32* %11
br label %50
41: ; preds = %28
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %18
br label %171
44: ; preds = %28
%45 = load i32, i32* @stderr
%46 = load i32, i32* %6
%47 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %46)
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %18
br label %171
50: ; preds = %38, %33, %30
br label %23
51: ; preds = %23
%52 = load i32, i32* @optind
%53 = load i32, i32* %4
%54 = icmp sge i32 %52, %53
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %18
br label %171
60: ; preds = %51
%61 = load i32, i32* @optind
store i32 %61, i32* %7
br label %62
62: ; preds = %167, %60
%63 = load i32, i32* %7
%64 = load i32, i32* %4
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %170
66: ; preds = %62
%67 = load i32, i32* %11
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %66
%70 = load i8**, i8*** %5
%71 = load i32, i32* %7
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %74)
br label %76
76: ; preds = %69, %66
%77 = load i8**, i8*** %5
%78 = load i32, i32* %7
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %77, i64 %79
%81 = load i8*, i8** %80
%82 = load i32, i32* @O_RDONLY
%83 = call i32 @open(i8* %81, i32 %82)
store i32 %83, i32* %9
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %91
85: ; preds = %76
%86 = load i32, i32* %10
%87 = icmp ne i32 %86, 0
br i1 %87, label %90, label %88
88: ; preds = %85
%89 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %90
90: ; preds = %88, %85
store i32 1, i32* %3
store i32 1, i32* %18
br label %171
91: ; preds = %76
%92 = load i32, i32* %11
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %101
94: ; preds = %91
%95 = load i8**, i8*** %5
%96 = load i32, i32* %7
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8*, i8** %95, i64 %97
%99 = load i8*, i8** %98
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %99)
br label %101
101: ; preds = %94, %91
%102 = call i32 @SHA1_Init(i32* %15)
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i64 4)
br label %104
104: ; preds = %109, %101
%105 = load i32, i32* %9
%106 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%107 = call i32 @read(i32 %105, i8* %106, i32 512)
store i32 %107, i32* %14
%108 = icmp sgt i32 %107, 0
br i1 %108, label %109, label %113
109: ; preds = %104
%110 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%111 = load i32, i32* %14
%112 = call i32 @SHA1_Update(i32* %15, i8* %110, i32 %111)
br label %104
113: ; preds = %104
%114 = load i32, i32* %14
%115 = icmp eq i32 %114, -1
br i1 %115, label %116, label %122
116: ; preds = %113
%117 = load i32, i32* %10
%118 = icmp ne i32 %117, 0
br i1 %118, label %121, label %119
119: ; preds = %116
%120 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %121
121: ; preds = %119, %116
store i32 1, i32* %3
store i32 1, i32* %18
br label %171
122: ; preds = %113
%123 = call i32 @SHA1_Final(i8* %22, i32* %15)
%124 = load i32, i32* %11
%125 = icmp ne i32 %124, 0
br i1 %125, label %126, label %133
126: ; preds = %122
%127 = load i8**, i8*** %5
%128 = load i32, i32* %7
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8*, i8** %127, i64 %129
%131 = load i8*, i8** %130
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i8* %131)
br label %133
133: ; preds = %126, %122
store i32 0, i32* %8
br label %134
134: ; preds = %145, %133
%135 = load i32, i32* %8
%136 = load i32, i32* @SHA_DIGEST_LENGTH
%137 = icmp slt i32 %135, %136
br i1 %137, label %138, label %148
138: ; preds = %134
%139 = load i32, i32* %8
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %22, i64 %140
%142 = load i8, i8* %141
%143 = zext i8 %142 to i32
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %143)
br label %145
145: ; preds = %138
%146 = load i32, i32* %8
%147 = add nsw i32 %146, 1
store i32 %147, i32* %8
br label %134
148: ; preds = %134
%149 = load i8**, i8*** %5
%150 = load i32, i32* %7
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i8*, i8** %149, i64 %151
%153 = load i8*, i8** %152
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i8* %153)
%155 = load i32, i32* %11
%156 = icmp ne i32 %155, 0
br i1 %156, label %157, label %164
157: ; preds = %148
%158 = load i8**, i8*** %5
%159 = load i32, i32* %7
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds i8*, i8** %158, i64 %160
%162 = load i8*, i8** %161
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i8* %162)
br label %164
164: ; preds = %157, %148
%165 = load i32, i32* %9
%166 = call i32 @close(i32 %165)
br label %167
167: ; preds = %164
%168 = load i32, i32* %7
%169 = add nsw i32 %168, 1
store i32 %169, i32* %7
br label %62
170: ; preds = %62
store i32 0, i32* %3
store i32 1, i32* %18
br label %171
171: ; preds = %170, %121, %90, %55, %44, %41, %36, %31
%172 = load i8*, i8** %16
%173 = load i32, i32* %3
ret i32 %173
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@SHA_DIGEST_LENGTH = global i32 0
@main.short_opt = internal global [5 x i8] c"hqVv\00"
@main.long_opt = internal global [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 113 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 113 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 118 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8 -128, i32 0, i32 86 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [7 x i8] c"silent\00"
@.str.2 = [6 x i8] c"quiet\00"
@.str.3 = [8 x i8] c"verbose\00"
@.str.4 = [8 x i8] c"version\00"
@stderr = global i32 0
@.str.5 = [39 x i8] c"Try `%s --help' for more information.\0A\00"
@.str.6 = [9 x i8] c"sha1hash\00"
@.str.7 = [32 x i8] c"%s: unrecognized option `--%c'\0A\00"
@optind = global i32 0
@.str.8 = [31 x i8] c"%s: missing required argument\0A\00"
@.str.9 = [17 x i8] c"opening \22%s\22...\0A\00"
@O_RDONLY = global i32 0
@.str.10 = [7 x i8] c"open()\00"
@.str.11 = [29 x i8] c"generating hash for \22%s\22...\0A\00"
@.str.12 = [21 x i8] c"sizeof(sha1) == %lu\0A\00"
@.str.13 = [29 x i8] c"displaying hash for \22%s\22...\0A\00"
@.str.14 = [5 x i8] c"%02x\00"
@.str.15 = [6 x i8] c" %s\0A\00"
@.str.16 = [17 x i8] c"closing \22%s\22...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca [512 x i8]
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = load i32, i32* @SHA_DIGEST_LENGTH
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
br label %13
13: ; preds = %22, %2
%14 = phi i32 [ %23, %22 ], [ 0, %2 ]
%15 = phi i32 [ %17, %22 ], [ 0, %2 ]
br label %16
16: ; preds = %13, %26
%17 = phi i32 [ %15, %13 ], [ %27, %26 ]
br label %18
18: ; preds = %16, %18
%19 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @main.short_opt, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.long_opt, i64 0, i64 0), i32* %3)
switch i32 %19, label %31 [
i32 -1, label %36
i32 63, label %28
i32 0, label %18
i32 104, label %20
i32 113, label %22
i32 86, label %24
i32 118, label %26
]
20: ; preds = %18
%21 = call i32 (...) @sha1hash_usage()
br label %113
22: ; preds = %18
%23 = add nuw nsw i32 %14, 1
br label %13
24: ; preds = %18
%25 = call i32 (...) @sha1hash_version()
br label %113
26: ; preds = %18
%27 = add nsw i32 %17, 1
br label %16
28: ; preds = %18
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %113
31: ; preds = %18
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %19)
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %113
36: ; preds = %18
%37 = load i32, i32* @optind
%38 = icmp slt i32 %37, %0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = icmp eq i32 %17, 0
%41 = sext i32 %37 to i64
br label %47
42: ; preds = %36
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %113
47: ; preds = %39, %108
%48 = phi i64 [ %41, %39 ], [ %110, %108 ]
br i1 %40, label %53, label %49
49: ; preds = %47
%50 = getelementptr inbounds i8*, i8** %1, i64 %48
%51 = load i8*, i8** %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %49, %47
%54 = getelementptr inbounds i8*, i8** %1, i64 %48
%55 = load i8*, i8** %54
%56 = load i32, i32* @O_RDONLY
%57 = call i32 @open(i8* %55, i32 %56)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %63
59: ; preds = %53
%60 = icmp eq i32 %14, 0
br i1 %60, label %61, label %113
61: ; preds = %59
%62 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %113
63: ; preds = %53
br i1 %40, label %67, label %64
64: ; preds = %63
%65 = load i8*, i8** %54
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %64, %63
%68 = call i32 @SHA1_Init(i32* %5)
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i64 4)
%70 = call i32 @read(i32 %57, i8* %7, i32 512)
%71 = icmp sgt i32 %70, 0
br i1 %71, label %72, label %77
72: ; preds = %67, %72
%73 = phi i32 [ %75, %72 ], [ %70, %67 ]
%74 = call i32 @SHA1_Update(i32* %5, i8* %7, i32 %73)
%75 = call i32 @read(i32 %57, i8* %7, i32 512)
%76 = icmp sgt i32 %75, 0
br i1 %76, label %72, label %77
77: ; preds = %72, %67
%78 = phi i32 [ %70, %67 ], [ %75, %72 ]
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %84
80: ; preds = %77
%81 = icmp eq i32 %14, 0
br i1 %81, label %82, label %113
82: ; preds = %80
%83 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %113
84: ; preds = %77
%85 = call i32 @SHA1_Final(i8* %12, i32* %5)
br i1 %40, label %89, label %86
86: ; preds = %84
%87 = load i8*, i8** %54
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i8* %87)
br label %89
89: ; preds = %86, %84
%90 = load i32, i32* @SHA_DIGEST_LENGTH
%91 = icmp sgt i32 %90, 0
br i1 %91, label %92, label %102
92: ; preds = %89, %92
%93 = phi i64 [ %98, %92 ], [ 0, %89 ]
%94 = getelementptr inbounds i8, i8* %12, i64 %93
%95 = load i8, i8* %94
%96 = zext i8 %95 to i32
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 %96)
%98 = add nuw nsw i64 %93, 1
%99 = load i32, i32* @SHA_DIGEST_LENGTH
%100 = sext i32 %99 to i64
%101 = icmp slt i64 %98, %100
br i1 %101, label %92, label %102
102: ; preds = %92, %89
%103 = load i8*, i8** %54
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i8* %103)
br i1 %40, label %108, label %105
105: ; preds = %102
%106 = load i8*, i8** %54
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i8* %106)
br label %108
108: ; preds = %105, %102
%109 = call i32 @close(i32 %57)
%110 = add nsw i64 %48, 1
%111 = trunc i64 %110 to i32
%112 = icmp eq i32 %111, %0
br i1 %112, label %113, label %47
113: ; preds = %108, %80, %82, %59, %61, %42, %31, %28, %24, %20
%114 = phi i32 [ 1, %31 ], [ 1, %28 ], [ 0, %24 ], [ 0, %20 ], [ 1, %42 ], [ 1, %61 ], [ 1, %59 ], [ 1, %82 ], [ 1, %80 ], [ 0, %108 ]
ret i32 %114
}