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

/* Variables and functions */
int /*<<< orphan*/ _getopt_reset(int, char **);
int _read_do(int, char **);
int _read_usage();
int getopt(int, char **, char *);
int optind;
int builtin_read(int argc, char *argv[]) {
  int o;
  _getopt_reset(argc, argv);
  while ((o = getopt(argc, argv, "r")) != -1)
    switch (o) {
    case 'r':
      break;
    default:
      return _read_usage();
    }
  return _read_do(argc - optind, &argv[optind]);
}


x86 assembly (clang, -O0):
<builtin_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <_getopt_reset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe97(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11a4 <builtin_read+0x64>
mov    -0x14(%rbp),%eax
sub    $0x72,%eax
jne    1190 <builtin_read+0x50>
jmp    118b <builtin_read+0x4b>
jmp    119f <builtin_read+0x5f>
mov    $0x0,%al
call   1040 <_read_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11cd <builtin_read+0x8d>
jmp    115b <builtin_read+0x1b>
mov    -0x8(%rbp),%edi
mov    0x2e3a(%rip),%rax
sub    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e2d(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1060 <_read_do@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_read>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
call   1030 <_getopt_reset@plt>
lea    0xeab(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
cmp    $0x72,%eax
je     1160 <builtin_read+0x20>
cmp    $0xffffffff,%eax
jne    1192 <builtin_read+0x52>
mov    0x2e6a(%rip),%rax
movslq (%rax),%rax
sub    %eax,%ebp
lea    (%rbx,%rax,8),%rsi
mov    %ebp,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <_read_do@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <_read_usage@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@optind = global i32 0
define i32 @builtin_read(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @_getopt_reset(i32 %7, i8** %8)
br label %10
10: ; preds = %20, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %18 [
i32 114, label %17
]
17: ; preds = %15
br label %20
18: ; preds = %15
%19 = call i32 (...) @_read_usage()
store i32 %19, i32* %3
br label %30
20: ; preds = %17
br label %10
21: ; preds = %10
%22 = load i32, i32* %4
%23 = load i32, i32* @optind
%24 = sub nsw i32 %22, %23
%25 = load i8**, i8*** %5
%26 = load i32, i32* @optind
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = call i32 @_read_do(i32 %24, i8** %28)
store i32 %29, i32* %3
br label %30
30: ; preds = %21, %18
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@optind = global i32 0
define i32 @builtin_read(i32 %0, i8** %1) {
%3 = tail call i32 @_getopt_reset(i32 %0, i8** %1)
br label %4
4: ; preds = %4, %2
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %5, label %6 [
i32 -1, label %8
i32 114, label %4
]
6: ; preds = %4
%7 = tail call i32 (...) @_read_usage()
br label %14
8: ; preds = %4
%9 = load i32, i32* @optind
%10 = sub nsw i32 %0, %9
%11 = sext i32 %9 to i64
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = tail call i32 @_read_do(i32 %10, i8** %12)
br label %14
14: ; preds = %8, %6
%15 = phi i32 [ %7, %6 ], [ %13, %8 ]
ret i32 %15
}