#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
unsigned int htonl(int);
unsigned int ntohl(int);
int /*<<< orphan*/ printf(char *, char *, ...);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  unsigned int a = 0;
  int b = 0;
  char c;
  int i;
  char *fmt = "%5s: %10u %11d\n";
  if (2 > argc) {
    fprintf(stderr, "Usage: %s <number to parse> [...]\n", *argv);
    return EXIT_FAILURE;
  }
  printf("%17s %11s\n", "unsigned", "signed");
  for (i = 1; i < argc; i += 1) {
    if (1 != sscanf(argv[i], "%u%c", &a, &c)) {
      fprintf(stderr, "Unable to scan %s as unsigned int\n", argv[i]);
    }
    if (1 != sscanf(argv[i], "%d%c", &b, &c)) {
      fprintf(stderr, "Unable to scan %s as int\n", argv[i]);
    }
    printf(fmt, "orig", a, b);
    printf(fmt, "ntohl", ntohl(a), ntohl(b));
    printf(fmt, "htonl", htonl(a), htonl(b));
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe85(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    $0x2,%eax
cmp    -0x8(%rbp),%eax
jle    11ba <main+0x6a>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1323 <main+0x1d3>
lea    0xe72(%rip),%rdi
lea    0xe76(%rip),%rsi
lea    0xe71(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1317 <main+0x1c7>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe4b(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x19(%rbp),%rcx
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     123b <main+0xeb>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe16(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe21(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x19(%rbp),%rcx
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     128d <main+0x13d>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdec(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <ntohl@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <ntohl@plt>
mov    -0x48(%rbp),%rdi
mov    -0x3c(%rbp),%edx
mov    %eax,%ecx
lea    0xdc3(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <htonl@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <htonl@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    %eax,%ecx
lea    0xd97(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11dd <main+0x8d>
mov    0x2cb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
cmp    $0x1,%edi
jg     119a <main+0x4a>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe87(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e43(%rip),%rax
jmp    12d8 <main+0x188>
mov    %edi,%ebp
lea    0xe90(%rip),%rdi
lea    0xe94(%rip),%rsi
lea    0xe8f(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
mov    %rax,0x10(%rsp)
mov    $0x1,%r13d
lea    0xf(%rsp),%r12
lea    0xe2f(%rip),%r14
jmp    1258 <main+0x108>
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
mov    %r14,%rdi
lea    0xe9c(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%edi
call   1070 <ntohl@plt>
mov    %eax,%r15d
mov    0x4(%rsp),%edi
call   1070 <ntohl@plt>
mov    %r14,%rdi
lea    0xe7b(%rip),%rsi
mov    %r15d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%edi
call   1040 <htonl@plt>
mov    %eax,%ebp
mov    0x4(%rsp),%edi
call   1040 <htonl@plt>
mov    %r14,%rdi
lea    0xe57(%rip),%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r13
cmp    %r13,0x10(%rsp)
je     12d1 <main+0x181>
mov    (%rbx,%r13,8),%rdi
lea    0xde4(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     1290 <main+0x140>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r13,8),%rdx
lea    0xdc1(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx,%r13,8),%rdi
lea    0xdd4(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     11e0 <main+0x90>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r13,8),%rdx
lea    0xdad(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11e0 <main+0x90>
mov    0x2cf8(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%5s: %10u %11d\0A\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"Usage: %s <number to parse> [...]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [11 x i8] c"%17s %11s\0A\00"
@.str.3 = [9 x i8] c"unsigned\00"
@.str.4 = [7 x i8] c"signed\00"
@.str.5 = [5 x i8] c"%u%c\00"
@.str.6 = [35 x i8] c"Unable to scan %s as unsigned int\0A\00"
@.str.7 = [5 x i8] c"%d%c\00"
@.str.8 = [26 x i8] c"Unable to scan %s as int\0A\00"
@.str.9 = [5 x i8] c"orig\00"
@.str.10 = [6 x i8] c"ntohl\00"
@.str.11 = [6 x i8] c"htonl\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = load i32, i32* %4
%12 = icmp sgt i32 2, %11
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %79
19: ; preds = %2
%20 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %9
br label %21
21: ; preds = %74, %19
%22 = load i32, i32* %9
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %77
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i8*, i8*, ...) @sscanf(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %6, i8* %8)
%32 = icmp ne i32 1, %31
br i1 %32, label %33, label %41
33: ; preds = %25
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %33, %25
%42 = load i8**, i8*** %5
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i8*, i8*, ...) @sscanf(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %7, i8* %8)
%48 = icmp ne i32 1, %47
br i1 %48, label %49, label %57
49: ; preds = %41
%50 = load i32, i32* @stderr
%51 = load i8**, i8*** %5
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %55)
br label %57
57: ; preds = %49, %41
%58 = load i8*, i8** %10
%59 = load i32, i32* %6
%60 = load i32, i32* %7
%61 = call i32 (i8*, i8*, ...) @printf(i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %59, i32 %60)
%62 = load i8*, i8** %10
%63 = load i32, i32* %6
%64 = call i32 @ntohl(i32 %63)
%65 = load i32, i32* %7
%66 = call i32 @ntohl(i32 %65)
%67 = call i32 (i8*, i8*, ...) @printf(i8* %62, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 %64, i32 %66)
%68 = load i8*, i8** %10
%69 = load i32, i32* %6
%70 = call i32 @htonl(i32 %69)
%71 = load i32, i32* %7
%72 = call i32 @htonl(i32 %71)
%73 = call i32 (i8*, i8*, ...) @printf(i8* %68, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %70, i32 %72)
br label %74
74: ; preds = %57
%75 = load i32, i32* %9
%76 = add nsw i32 %75, 1
store i32 %76, i32* %9
br label %21
77: ; preds = %21
%78 = load i32, i32* @EXIT_SUCCESS
store i32 %78, i32* %3
br label %79
79: ; preds = %77, %13
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@.str = [16 x i8] c"%5s: %10u %11d\0A\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"Usage: %s <number to parse> [...]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [11 x i8] c"%17s %11s\0A\00"
@.str.3 = [9 x i8] c"unsigned\00"
@.str.4 = [7 x i8] c"signed\00"
@.str.5 = [5 x i8] c"%u%c\00"
@.str.6 = [35 x i8] c"Unable to scan %s as unsigned int\0A\00"
@.str.7 = [5 x i8] c"%d%c\00"
@.str.8 = [26 x i8] c"Unable to scan %s as int\0A\00"
@.str.9 = [5 x i8] c"orig\00"
@.str.10 = [6 x i8] c"ntohl\00"
@.str.11 = [6 x i8] c"htonl\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = icmp slt i32 %0, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %50
13: ; preds = %2
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%15 = zext i32 %0 to i64
br label %16
16: ; preds = %13, %34
%17 = phi i64 [ 1, %13 ], [ %48, %34 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 (i8*, i8*, ...) @sscanf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %3, i8* %5)
%21 = icmp eq i32 %20, 1
br i1 %21, label %26, label %22
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %18
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %22, %16
%27 = load i8*, i8** %18
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %4, i8* %5)
%29 = icmp eq i32 %28, 1
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %18
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %30, %26
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %35, i32 %36)
%38 = load i32, i32* %3
%39 = call i32 @ntohl(i32 %38)
%40 = load i32, i32* %4
%41 = call i32 @ntohl(i32 %40)
%42 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 %39, i32 %41)
%43 = load i32, i32* %3
%44 = call i32 @htonl(i32 %43)
%45 = load i32, i32* %4
%46 = call i32 @htonl(i32 %45)
%47 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %44, i32 %46)
%48 = add nuw nsw i64 %17, 1
%49 = icmp eq i64 %48, %15
br i1 %49, label %50, label %16
50: ; preds = %34, %9
%51 = phi i32* [ @EXIT_FAILURE, %9 ], [ @EXIT_SUCCESS, %34 ]
%52 = load i32, i32* %51
ret i32 %52
}