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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int getopt_long(int, char const **, char *, struct option *, int *);
int /*<<< orphan*/ optarg;
size_t optind;
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ required_argument;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int main(int argc, const char *argv[]) {
  if (argc < 2) {
    usage();
  }
  struct option long_options[] = {{"tabs", required_argument, 0, 't'},
                                  {0, 0, 0, 0}};
  int tab_width = 8;
  int option_index = 0;
  int c;
  while ((c = getopt_long(argc, argv, "t:", long_options, &option_index)) !=
         -1) {
    switch (c) {
    case 't':
      tab_width = atoi(optarg);
      if (tab_width <= 0) {
        usage();
      }
      break;
    default:
      usage();
    }
  }
  FILE *fp;
  for (size_t i = optind; i < argc; i++) {
    fp = fopen(argv[i], "r");
    if (fp == NULL) {
      fprintf(stderr, "can't open file %s\n", argv[i]);
      exit(EXIT_FAILURE);
    } else {
      int ch;
      while ((ch = fgetc(fp)) != EOF) {
        if (ch == '\t') {
          for (size_t j = 0; j < tab_width; j++) {
            putchar(' ');
          }
        } else {
          putchar(ch);
        }
      }
      fclose(fp);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c7 <main+0x27>
mov    $0x0,%al
call   1090 <usage@plt>
lea    -0x40(%rbp),%rdi
lea    0xe2e(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2df3(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x74,-0x30(%rbp)
add    $0x18,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
movl   $0x8,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rcx
lea    0xde5(%rip),%rdx
lea    -0x48(%rbp),%r8
call   1050 <getopt_long@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0xffffffff,%eax
je     1279 <main+0xd9>
mov    -0x4c(%rbp),%eax
sub    $0x74,%eax
jne    126d <main+0xcd>
jmp    1246 <main+0xa6>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
call   10b0 <atoi@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jg     1268 <main+0xc8>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    1274 <main+0xd4>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    120e <main+0x6e>
mov    0x2d58(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    137d <main+0x1dd>
mov    -0x10(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd5d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12ee <main+0x14e>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd2f(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    12f3 <main+0x153>
mov    -0x58(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x64(%rbp)
mov    0x2cda(%rip),%rcx
cmp    (%rcx),%eax
je     135e <main+0x1be>
cmpl   $0x9,-0x64(%rbp)
jne    1351 <main+0x1b1>
movq   $0x0,-0x70(%rbp)
mov    -0x70(%rbp),%rax
movslq -0x44(%rbp),%rcx
cmp    %rcx,%rax
jae    134c <main+0x1ac>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    1320 <main+0x180>
jmp    1359 <main+0x1b9>
mov    -0x64(%rbp),%edi
call   1030 <putchar@plt>
jmp    12f3 <main+0x153>
mov    -0x58(%rbp),%rdi
call   1040 <fclose@plt>
jmp    136c <main+0x1cc>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1287 <main+0xe7>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r15
mov    %edi,%ebx
cmp    $0x1,%edi
jg     11af <main+0x1f>
xor    %eax,%eax
call   1080 <usage@plt>
lea    0xe4a(%rip),%rax
mov    %rax,0x20(%rsp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%al
mov    %al,0x28(%rsp)
movabs $0x7400000000,%rax
mov    %rax,0x2c(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x38(%rsp)
movq   $0x0,0x48(%rsp)
movl   $0x0,0xc(%rsp)
mov    $0x8,%ebp
lea    0xe09(%rip),%r14
lea    0x20(%rsp),%r12
lea    0xc(%rsp),%r13
jmp    121c <main+0x8c>
nopl   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     124a <main+0xba>
xor    %eax,%eax
call   1080 <usage@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1050 <getopt_long@plt>
cmp    $0x74,%eax
jne    1210 <main+0x80>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   10a0 <atoi@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     121c <main+0x8c>
jmp    1215 <main+0x85>
mov    %r15,0x10(%rsp)
mov    0x2d82(%rip),%rax
mov    (%rax),%r12
movslq %ebx,%rax
mov    %rax,0x18(%rsp)
cmp    %rax,%r12
jae    1312 <main+0x182>
cmp    $0x2,%ebp
mov    $0x1,%eax
cmovae %ebp,%eax
movslq %eax,%r15
mov    0x2d61(%rip),%r13
jmp    12a3 <main+0x113>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x1,%r12
cmp    0x18(%rsp),%r12
je     1312 <main+0x182>
mov    0x10(%rsp),%rax
mov    (%rax,%r12,8),%rdi
lea    0xd55(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1323 <main+0x193>
mov    %rax,%rbx
jmp    12d7 <main+0x147>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%r13),%eax
je     1290 <main+0x100>
cmp    $0x9,%eax
jne    12d0 <main+0x140>
test   %ebp,%ebp
je     12d7 <main+0x147>
mov    %r15,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%r14
jne    1300 <main+0x170>
jmp    12d7 <main+0x147>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rsp),%rax
mov    (%rax,%r12,8),%rdx
lea    0xcce(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [5 x i8] c"tabs\00"
@required_argument = global i32 0
@.str.1 = [3 x i8] c"t:\00"
@optarg = global i32 0
@optind = global i64 0
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [20 x i8] c"can't open file %s\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x %struct.option]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (...) @usage()
br label %18
18: ; preds = %16, %2
%19 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %6, i64 0, i64 0
%20 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 1
%22 = load i32, i32* @required_argument
%23 = trunc i32 %22 to i8
store i8 %23, i8* %21
%24 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 2
store i32 0, i32* %24
%25 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 3
store i32 116, i32* %25
%26 = getelementptr inbounds %struct.option, %struct.option* %19, i64 1
%27 = bitcast %struct.option* %26 to i8*
store i32 8, i32* %7
store i32 0, i32* %8
br label %28
28: ; preds = %46, %18
%29 = load i32, i32* %4
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %6, i64 0, i64 0
%32 = call i32 @getopt_long(i32 %29, i8** %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.option* %31, i32* %8)
store i32 %32, i32* %9
%33 = icmp ne i32 %32, -1
br i1 %33, label %34, label %47
34: ; preds = %28
%35 = load i32, i32* %9
switch i32 %35, label %44 [
i32 116, label %36
]
36: ; preds = %34
%37 = load i32, i32* @optarg
%38 = call i32 @atoi(i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp sle i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 (...) @usage()
br label %43
43: ; preds = %41, %36
br label %46
44: ; preds = %34
%45 = call i32 (...) @usage()
br label %46
46: ; preds = %44, %43
br label %28
47: ; preds = %28
%48 = load i64, i64* @optind
store i64 %48, i64* %11
br label %49
49: ; preds = %100, %47
%50 = load i64, i64* %11
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = icmp ult i64 %50, %52
br i1 %53, label %54, label %103
54: ; preds = %49
%55 = load i8**, i8*** %5
%56 = load i64, i64* %11
%57 = getelementptr inbounds i8*, i8** %55, i64 %56
%58 = load i8*, i8** %57
%59 = call i32* @fopen(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %59, i32** %10
%60 = load i32*, i32** %10
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %71
62: ; preds = %54
%63 = load i32, i32* @stderr
%64 = load i8**, i8*** %5
%65 = load i64, i64* %11
%66 = getelementptr inbounds i8*, i8** %64, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %67)
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %54
br label %72
72: ; preds = %95, %71
%73 = load i32*, i32** %10
%74 = call i32 @fgetc(i32* %73)
store i32 %74, i32* %12
%75 = load i32, i32* @EOF
%76 = icmp ne i32 %74, %75
br i1 %76, label %77, label %96
77: ; preds = %72
%78 = load i32, i32* %12
%79 = icmp eq i32 %78, 9
br i1 %79, label %80, label %92
80: ; preds = %77
store i64 0, i64* %13
br label %81
81: ; preds = %88, %80
%82 = load i64, i64* %13
%83 = load i32, i32* %7
%84 = sext i32 %83 to i64
%85 = icmp ult i64 %82, %84
br i1 %85, label %86, label %91
86: ; preds = %81
%87 = call i32 @putchar(i32 32)
br label %88
88: ; preds = %86
%89 = load i64, i64* %13
%90 = add i64 %89, 1
store i64 %90, i64* %13
br label %81
91: ; preds = %81
br label %95
92: ; preds = %77
%93 = load i32, i32* %12
%94 = call i32 @putchar(i32 %93)
br label %95
95: ; preds = %92, %91
br label %72
96: ; preds = %72
%97 = load i32*, i32** %10
%98 = call i32 @fclose(i32* %97)
br label %99
99: ; preds = %96
br label %100
100: ; preds = %99
%101 = load i64, i64* %11
%102 = add i64 %101, 1
store i64 %102, i64* %11
br label %49
103: ; preds = %49
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [5 x i8] c"tabs\00"
@required_argument = global i32 0
@.str.1 = [3 x i8] c"t:\00"
@optarg = global i32 0
@optind = global i64 0
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [20 x i8] c"can't open file %s\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x %struct.option]
%4 = alloca i32
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @usage()
br label %8
8: ; preds = %6, %2
%9 = bitcast [2 x %struct.option]* %3 to i8*
%10 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0
%11 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 1
%13 = load i32, i32* @required_argument
%14 = trunc i32 %13 to i8
store i8 %14, i8* %12
%15 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 2
store i32 0, i32* %15
%16 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 3
store i32 116, i32* %16
%17 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 1
%18 = bitcast %struct.option* %17 to i8*
%19 = bitcast i32* %4 to i8*
store i32 0, i32* %4
br label %20
20: ; preds = %30, %8
%21 = phi i32 [ 8, %8 ], [ %31, %30 ]
%22 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.option* %10, i32* %4)
switch i32 %22, label %27 [
i32 -1, label %32
i32 116, label %23
]
23: ; preds = %20
%24 = load i32, i32* @optarg
%25 = call i32 @atoi(i32 %24)
%26 = icmp slt i32 %25, 1
br i1 %26, label %27, label %30
27: ; preds = %20, %23
%28 = phi i32 [ %25, %23 ], [ %21, %20 ]
%29 = call i32 (...) @usage()
br label %30
30: ; preds = %27, %23
%31 = phi i32 [ %25, %23 ], [ %28, %27 ]
br label %20
32: ; preds = %20
%33 = load i64, i64* @optind
%34 = sext i32 %0 to i64
%35 = icmp ult i64 %33, %34
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = icmp eq i32 %21, 0
%38 = call i32 @llvm.umax.i32(i32 %21, i32 1)
%39 = sext i32 %38 to i64
br label %41
40: ; preds = %73, %32
ret i32 0
41: ; preds = %36, %73
%42 = phi i64 [ %33, %36 ], [ %75, %73 ]
%43 = getelementptr inbounds i8*, i8** %1, i64 %42
%44 = load i8*, i8** %43
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %51, label %47
47: ; preds = %41
%48 = call i32 @fgetc(i32* %45)
%49 = load i32, i32* @EOF
%50 = icmp eq i32 %48, %49
br i1 %50, label %73, label %58
51: ; preds = %41
%52 = getelementptr inbounds i8*, i8** %1, i64 %42
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %52
%55 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %54)
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %47, %69
%59 = phi i32 [ %70, %69 ], [ %48, %47 ]
%60 = icmp eq i32 %59, 9
br i1 %60, label %61, label %67
61: ; preds = %58
br i1 %37, label %69, label %62
62: ; preds = %61, %62
%63 = phi i64 [ %65, %62 ], [ 0, %61 ]
%64 = call i32 @putchar(i32 32)
%65 = add nuw i64 %63, 1
%66 = icmp eq i64 %65, %39
br i1 %66, label %69, label %62
67: ; preds = %58
%68 = call i32 @putchar(i32 %59)
br label %69
69: ; preds = %62, %61, %67
%70 = call i32 @fgetc(i32* %45)
%71 = load i32, i32* @EOF
%72 = icmp eq i32 %70, %71
br i1 %72, label %73, label %58
73: ; preds = %69, %47
%74 = call i32 @fclose(i32* %45)
%75 = add nuw i64 %42, 1
%76 = icmp eq i64 %75, %34
br i1 %76, label %40, label %41
}