#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ eprintf(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ setprogname(char *);
int /*<<< orphan*/ strings(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ weprintf(char *, char *);
int main(int argc, char *argv[]) {
  int i;
  FILE *fin;
  setprogname("strings");
  if (argc == 1)
    eprintf("usage: strings filenames");
  else {
    for (i = 1; i < argc; i++) {
      if ((fin = fopen(argv[i], "rb")) == NULL)
        weprintf("can't open %s:", argv[i]);
      else {
        strings(argv[i], fin);
        fclose(fin);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
call   1080 <setprogname@plt>
cmpl   $0x1,-0x8(%rbp)
jne    119d <main+0x3d>
lea    0xe75(%rip),%rdi
call   1060 <eprintf@plt>
jmp    1229 <main+0xc9>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1224 <main+0xc4>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe5e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11f3 <main+0x93>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe3b(%rip),%rdi
call   1050 <weprintf@plt>
jmp    1211 <main+0xb1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strings@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1216 <main+0xb6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <main+0x44>
jmp    1229 <main+0xc9>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebp
lea    0xe89(%rip),%rdi
call   1080 <setprogname@plt>
cmp    $0x1,%ebp
jne    118f <main+0x2f>
lea    0xe80(%rip),%rdi
call   1060 <eprintf@plt>
jmp    11f0 <main+0x90>
jle    11f0 <main+0x90>
mov    %ebp,%r12d
mov    $0x1,%ebx
lea    0xe81(%rip),%r14
lea    0xe7d(%rip),%r15
jmp    11cf <main+0x6f>
nopl   0x0(%rax)
mov    %rax,%rbp
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <strings@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     11f0 <main+0x90>
mov    0x0(%r13,%rbx,8),%rdi
mov    %r14,%rsi
call   1070 <fopen@plt>
mov    0x0(%r13,%rbx,8),%rsi
test   %rax,%rax
jne    11b0 <main+0x50>
mov    %r15,%rdi
call   1050 <weprintf@plt>
jmp    11c6 <main+0x66>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"strings\00"
@.str.1 = [25 x i8] c"usage: strings filenames\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [15 x i8] c"can't open %s:\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @setprogname(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @eprintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %48
13: ; preds = %2
store i32 1, i32* %6
br label %14
14: ; preds = %44, %13
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %47
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %24, i32** %7
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %33
26: ; preds = %18
%27 = load i8**, i8*** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @weprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %31)
br label %43
33: ; preds = %18
%34 = load i8**, i8*** %5
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = load i32*, i32** %7
%40 = call i32 @strings(i8* %38, i32* %39)
%41 = load i32*, i32** %7
%42 = call i32 @fclose(i32* %41)
br label %43
43: ; preds = %33, %26
br label %44
44: ; preds = %43
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %14
47: ; preds = %14
br label %48
48: ; preds = %47, %11
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"strings\00"
@.str.1 = [25 x i8] c"usage: strings filenames\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [15 x i8] c"can't open %s:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @setprogname(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %0, 1
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %26
7: ; preds = %5
%8 = zext i32 %0 to i64
br label %11
9: ; preds = %2
%10 = tail call i32 @eprintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %26
11: ; preds = %7, %23
%12 = phi i64 [ 1, %7 ], [ %24, %23 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32* %15, null
%17 = load i8*, i8** %13
br i1 %16, label %18, label %20
18: ; preds = %11
%19 = tail call i32 @weprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %23
20: ; preds = %11
%21 = tail call i32 @strings(i8* %17, i32* %15)
%22 = tail call i32 @fclose(i32* %15)
br label %23
23: ; preds = %18, %20
%24 = add nuw nsw i64 %12, 1
%25 = icmp eq i64 %24, %8
br i1 %25, label %26, label %11
26: ; preds = %23, %5, %9
ret i32 0
}