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

/* Variables and functions */
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
size_t fwrite(unsigned long **, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int);
unsigned long strtoul(char *, char **, int /*<<< orphan*/);
int do_work(int argc, char *argv[], const char *name) {
  int index;
  unsigned long nums[argc - 1];
  char *endptr;
  char *start;
  size_t result;
  for (index = 1; index < argc; index++) {
    start = argv[index];
    if (*start == (char)0) {
      fprintf(stderr, "%s: argument %d is empty.\n", name, index);
      return 1;
    }
    errno = 0;
    nums[index - 1] = strtoul(start, &endptr, 0);
    if (errno != 0) {
      fprintf(stderr, "%s: can't convert '%s'. Errno=%d (%s)\n", name, start,
              errno, strerror(errno));
      return 1;
    }
    if (*endptr != (char)0) {
      fprintf(stderr, "%s: there is illegal symbols in '%s'.\n", name, start);
      return 1;
    }
  }
  result = fwrite(&nums, 1, sizeof(nums), stdout);
  if (result != sizeof(nums)) {
    fprintf(stderr, "%s: can't write to the stdout. Errno=%d (%s).\n", name,
            errno, strerror(errno));
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<do_work>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %rax,-0x60(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12e6 <do_work+0x1a6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11e8 <do_work+0xa8>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    1396 <do_work+0x256>
mov    0x2de9(%rip),%rax
movl   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
lea    -0x38(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %rax,%rdx
mov    -0x58(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x2db9(%rip),%rax
cmpl   $0x0,(%rax)
je     1291 <do_work+0x151>
mov    0x2db1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rdx
mov    -0x70(%rbp),%rcx
mov    -0x64(%rbp),%r8d
mov    %rax,%r9
lea    0xda4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    1396 <do_work+0x256>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12d3 <do_work+0x193>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xd89(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    1396 <do_work+0x256>
jmp    12d8 <do_work+0x198>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118b <do_work+0x4b>
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rdi
shl    $0x3,%rax
mov    %eax,%edx
mov    0x2cd5(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1050 <fwrite@plt>
mov    -0x60(%rbp),%rcx
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shl    $0x3,%rcx
cmp    %rcx,%rax
je     1388 <do_work+0x248>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    0x2c97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%rdx
mov    -0x80(%rbp),%ecx
mov    %rax,%r8
lea    0xcfb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    1396 <do_work+0x256>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_work>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,-0x30(%rbp)
mov    %rsi,-0x48(%rbp)
lea    -0x1(%rdi),%eax
mov    %rsp,%r13
mov    %rax,-0x38(%rbp)
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
cmp    $0x2,%edi
jl     11e0 <do_work+0xa0>
mov    %edi,%eax
mov    %rax,-0x40(%rbp)
mov    $0x1,%r14d
mov    0x2e4b(%rip),%r12
nopl   (%rax)
mov    -0x48(%rbp),%rax
mov    (%rax,%r14,8),%rbx
cmpb   $0x0,(%rbx)
je     1244 <do_work+0x104>
movl   $0x0,(%r12)
mov    %rbx,%rdi
lea    -0x50(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x8(%r13,%r14,8)
mov    (%r12),%r15d
test   %r15d,%r15d
jne    1264 <do_work+0x124>
mov    -0x50(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1296 <do_work+0x156>
add    $0x1,%r14
cmp    %r14,-0x40(%rbp)
jne    1190 <do_work+0x50>
mov    -0x38(%rbp),%rbx
shl    $0x3,%rbx
mov    0x2de1(%rip),%rax
mov    (%rax),%ecx
mov    %r13,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1050 <fwrite@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rbx,%rcx
je     12b9 <do_work+0x179>
mov    0x2dcb(%rip),%rax
mov    (%rax),%r14d
mov    0x2db9(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1060 <strerror@plt>
lea    0xe3a(%rip),%rsi
mov    %r14d,%edi
mov    -0x30(%rbp),%rdx
mov    %ebx,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    12b4 <do_work+0x174>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
lea    0xdac(%rip),%rsi
mov    -0x30(%rbp),%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    12b4 <do_work+0x174>
mov    0x2d75(%rip),%rax
mov    (%rax),%r14d
mov    %r15d,%edi
call   1060 <strerror@plt>
lea    0xd9e(%rip),%rsi
mov    %r14d,%edi
mov    -0x30(%rbp),%rdx
mov    %rbx,%rcx
mov    %r15d,%r8d
mov    %rax,%r9
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    12b4 <do_work+0x174>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
mov    -0x30(%rbp),%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"%s: argument %d is empty.\0A\00"
@errno = global i32 0
@.str.1 = [39 x i8] c"%s: can't convert '%s'. Errno=%d (%s)\0A\00"
@.str.2 = [39 x i8] c"%s: there is illegal symbols in '%s'.\0A\00"
@stdout = global i32 0
@.str.3 = [47 x i8] c"%s: can't write to the stdout. Errno=%d (%s).\0A\00"
define i32 @do_work(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
%15 = load i32, i32* %5
%16 = sub nsw i32 %15, 1
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %9
%19 = alloca i64, i64 %17
store i64 %17, i64* %10
store i32 1, i32* %8
br label %20
20: ; preds = %67, %3
%21 = load i32, i32* %8
%22 = load i32, i32* %5
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %70
24: ; preds = %20
%25 = load i8**, i8*** %6
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
store i8* %29, i8** %12
%30 = load i8*, i8** %12
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %24
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %7
%37 = load i32, i32* %8
%38 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %36, i32 %37)
store i32 1, i32* %4
store i32 1, i32* %14
br label %87
39: ; preds = %24
store i32 0, i32* @errno
%40 = load i8*, i8** %12
%41 = call i64 @strtoul(i8* %40, i8** %11, i32 0)
%42 = load i32, i32* %8
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i64, i64* %19, i64 %44
store i64 %41, i64* %45
%46 = load i32, i32* @errno
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %56
48: ; preds = %39
%49 = load i32, i32* @stderr
%50 = load i8*, i8** %7
%51 = load i8*, i8** %12
%52 = load i32, i32* @errno
%53 = load i32, i32* @errno
%54 = call i8* @strerror(i32 %53)
%55 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %50, i8* %51, i32 %52, i8* %54)
store i32 1, i32* %4
store i32 1, i32* %14
br label %87
56: ; preds = %39
%57 = load i8*, i8** %11
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %7
%64 = load i8*, i8** %12
%65 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %63, i8* %64)
store i32 1, i32* %4
store i32 1, i32* %14
br label %87
66: ; preds = %56
br label %67
67: ; preds = %66
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
store i32 %69, i32* %8
br label %20
70: ; preds = %20
%71 = bitcast i64* %19 to i64**
%72 = mul nuw i64 8, %17
%73 = trunc i64 %72 to i32
%74 = load i32, i32* @stdout
%75 = call i64 @fwrite(i64** %71, i32 1, i32 %73, i32 %74)
store i64 %75, i64* %13
%76 = load i64, i64* %13
%77 = mul nuw i64 8, %17
%78 = icmp ne i64 %76, %77
br i1 %78, label %79, label %86
79: ; preds = %70
%80 = load i32, i32* @stderr
%81 = load i8*, i8** %7
%82 = load i32, i32* @errno
%83 = load i32, i32* @errno
%84 = call i8* @strerror(i32 %83)
%85 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %81, i32 %82, i8* %84)
store i32 1, i32* %4
store i32 1, i32* %14
br label %87
86: ; preds = %70
store i32 0, i32* %4
store i32 1, i32* %14
br label %87
87: ; preds = %86, %79, %61, %48, %34
%88 = load i8*, i8** %9
%89 = load i32, i32* %4
ret i32 %89
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"%s: argument %d is empty.\0A\00"
@errno = global i32 0
@.str.1 = [39 x i8] c"%s: can't convert '%s'. Errno=%d (%s)\0A\00"
@.str.2 = [39 x i8] c"%s: there is illegal symbols in '%s'.\0A\00"
@stdout = global i32 0
@.str.3 = [47 x i8] c"%s: can't write to the stdout. Errno=%d (%s).\0A\00"
define i32 @do_work(i32 %0, i8** nocapture %1, i8* %2) {
%4 = alloca i8*
%5 = add nsw i32 %0, -1
%6 = zext i32 %5 to i64
%7 = alloca i64, i64 %6
%8 = bitcast i8** %4 to i8*
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %42
10: ; preds = %3
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %10, %39
%13 = phi i64 [ 1, %10 ], [ %40, %39 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = trunc i64 %13 to i32
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %19)
br label %54
22: ; preds = %12
store i32 0, i32* @errno
%23 = call i64 @strtoul(i8* %15, i8** %4, i32 0)
%24 = add nsw i64 %13, -1
%25 = getelementptr inbounds i64, i64* %7, i64 %24
store i64 %23, i64* %25
%26 = load i32, i32* @errno
%27 = icmp eq i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = tail call i8* @strerror(i32 %26)
%31 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %15, i32 %26, i8* %30)
br label %54
32: ; preds = %22
%33 = load i8*, i8** %4
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %15)
br label %54
39: ; preds = %32
%40 = add nuw nsw i64 %13, 1
%41 = icmp eq i64 %40, %11
br i1 %41, label %42, label %12
42: ; preds = %39, %3
%43 = bitcast i64* %7 to i64**
%44 = shl nuw nsw i64 %6, 3
%45 = trunc i64 %44 to i32
%46 = load i32, i32* @stdout
%47 = call i64 @fwrite(i64** %43, i32 1, i32 %45, i32 %46)
%48 = icmp eq i64 %47, %44
br i1 %48, label %54, label %49
49: ; preds = %42
%50 = load i32, i32* @stderr
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %2, i32 %51, i8* %52)
br label %54
54: ; preds = %42, %49, %36, %28, %18
%55 = phi i32 [ 1, %18 ], [ 1, %28 ], [ 1, %36 ], [ 1, %49 ], [ 0, %42 ]
ret i32 %55
}