void testReadUInt() {
  char str[255];
  char *msg = &str;
  char passed = 1;
  char signedChar;
  unsigned int unsignedInt;
  printf("Testing fiolSReadUInt...\r\n");
  msg = "28 4489";
  passed = 1;
  printf("\t(\"%s\")\r\n", msg);
  msg += fiolSReadUInt(msg, &unsignedInt);
  if (unsignedInt != 28) {
    printf("\t\tfailed, returned %d instead of %d\r\n", unsignedInt, 28);
    passed = 0;
  }
  msg += fiolSReadChar(msg, &signedChar);
  if (signedChar != ' ') {
    printf("\t\tfailed, returned '%c' instead of '%c'\r\n", signedChar, ' ');
    passed = 0;
  }
  msg += fiolSReadUInt(msg, &unsignedInt);
  if (unsignedInt != 4489) {
    printf("\t\tfailed, returned %d instead of %d\r\n", unsignedInt, 4489);
    passed = 0;
  }
  if (passed == 1)
    printf("\t\tPassed!\r\n");
}


x86 assembly (clang, -O0):
<testReadUInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    -0x100(%rbp),%rax
mov    %rax,-0x108(%rbp)
movb   $0x1,-0x109(%rbp)
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rax
mov    %rax,-0x108(%rbp)
movb   $0x1,-0x109(%rbp)
mov    -0x108(%rbp),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x108(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0x0,%al
call   1040 <fiolSReadUInt@plt>
mov    %eax,%ecx
mov    -0x108(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x108(%rbp)
cmpl   $0x1c,-0x110(%rbp)
je     11e0 <testReadUInt+0xb0>
mov    -0x110(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x1c,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x0,-0x109(%rbp)
mov    -0x108(%rbp),%rdi
lea    -0x10a(%rbp),%rsi
mov    $0x0,%al
call   1050 <fiolSReadChar@plt>
mov    %eax,%ecx
mov    -0x108(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x108(%rbp)
movsbl -0x10a(%rbp),%eax
cmp    $0x20,%eax
je     123c <testReadUInt+0x10c>
movsbl -0x10a(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x20,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x0,-0x109(%rbp)
mov    -0x108(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0x0,%al
call   1040 <fiolSReadUInt@plt>
mov    %eax,%ecx
mov    -0x108(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x108(%rbp)
cmpl   $0x1189,-0x110(%rbp)
je     1297 <testReadUInt+0x167>
mov    -0x110(%rbp),%esi
lea    0xda9(%rip),%rdi
mov    $0x1189,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x0,-0x109(%rbp)
movsbl -0x109(%rbp),%eax
cmp    $0x1,%eax
jne    12b5 <testReadUInt+0x185>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testReadUInt>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xf13(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
lea    0xe9e(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fiolSReadUInt@plt>
movslq %eax,%rbx
add    %r14,%rbx
mov    0xc(%rsp),%esi
mov    $0x1,%ebp
cmp    $0x1c,%esi
je     11a4 <testReadUInt+0x64>
lea    0xe7c(%rip),%rdi
mov    $0x1c,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
lea    0xb(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <fiolSReadChar@plt>
movslq %eax,%r14
add    %rbx,%r14
movsbl 0xb(%rsp),%esi
cmp    $0x20,%esi
je     11d8 <testReadUInt+0x98>
lea    0xe6e(%rip),%rdi
mov    $0x20,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fiolSReadUInt@plt>
mov    0xc(%rsp),%esi
cmp    $0x1189,%esi
jne    1205 <testReadUInt+0xc5>
test   %ebp,%ebp
je     1218 <testReadUInt+0xd8>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
jmp    1218 <testReadUInt+0xd8>
lea    0xe06(%rip),%rdi
mov    $0x1189,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Testing fiolSReadUInt...\0D\0A\00"
@.str.1 = [8 x i8] c"28 4489\00"
@.str.2 = [10 x i8] c"\09(\22%s\22)\0D\0A\00"
@.str.3 = [38 x i8] c"\09\09failed, returned %d instead of %d\0D\0A\00"
@.str.4 = [42 x i8] c"\09\09failed, returned '%c' instead of '%c'\0D\0A\00"
@.str.5 = [12 x i8] c"\09\09Passed!\0D\0A\00"
define void @testReadUInt() {
%1 = alloca [255 x i8]
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = bitcast [255 x i8]* %1 to i8*
store i8* %6, i8** %2
store i8 1, i8* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8 1, i8* %3
%8 = load i8*, i8** %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %2
%11 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @fiolSReadUInt to i32 (i8*, i32*, ...)*)(i8* %10, i32* %5)
%12 = load i8*, i8** %2
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %2
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 28
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = load i32, i32* %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 28)
store i8 0, i8* %3
br label %20
20: ; preds = %17, %0
%21 = load i8*, i8** %2
%22 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @fiolSReadChar to i32 (i8*, i8*, ...)*)(i8* %21, i8* %4)
%23 = load i8*, i8** %2
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %2
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 32
br i1 %28, label %29, label %33
29: ; preds = %20
%30 = load i8, i8* %4
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 32)
store i8 0, i8* %3
br label %33
33: ; preds = %29, %20
%34 = load i8*, i8** %2
%35 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @fiolSReadUInt to i32 (i8*, i32*, ...)*)(i8* %34, i32* %5)
%36 = load i8*, i8** %2
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8* %38, i8** %2
%39 = load i32, i32* %5
%40 = icmp ne i32 %39, 4489
br i1 %40, label %41, label %44
41: ; preds = %33
%42 = load i32, i32* %5
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %42, i32 4489)
store i8 0, i8* %3
br label %44
44: ; preds = %41, %33
%45 = load i8, i8* %3
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
ret void
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"28 4489\00"
@.str.2 = [10 x i8] c"\09(\22%s\22)\0D\0A\00"
@.str.3 = [38 x i8] c"\09\09failed, returned %d instead of %d\0D\0A\00"
@.str.4 = [42 x i8] c"\09\09failed, returned '%c' instead of '%c'\0D\0A\00"
@str = [26 x i8] c"Testing fiolSReadUInt...\0D\00"
@str.6 = [11 x i8] c"\09\09Passed!\0D\00"
define void @testReadUInt() {
%1 = alloca i8
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @fiolSReadUInt to i32 (i8*, i32*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [8 x i8], [8 x i8]* @.str.1, i64 0, i64 %7
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 28
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 28)
br label %13
13: ; preds = %11, %0
%14 = phi i32 [ 0, %11 ], [ 1, %0 ]
%15 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @fiolSReadChar to i32 (i8*, i8*, ...)*)(i8* %8, i8* %1)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %8, i64 %16
%18 = load i8, i8* %1
%19 = icmp eq i8 %18, 32
br i1 %19, label %23, label %20
20: ; preds = %13
%21 = sext i8 %18 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %21, i32 32)
br label %23
23: ; preds = %20, %13
%24 = phi i32 [ 0, %20 ], [ %14, %13 ]
%25 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @fiolSReadUInt to i32 (i8*, i32*, ...)*)(i8* %17, i32* %2)
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 4489
br i1 %27, label %30, label %28
28: ; preds = %23
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 4489)
br label %34
30: ; preds = %23
%31 = icmp eq i32 %24, 1
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
br label %34
34: ; preds = %28, %32, %30
ret void
}