#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*/ sw_getn(char *, int);
int /*<<< orphan*/ sw_printf(char *, ...);
int /*<<< orphan*/ sw_putchar(int);
int /*<<< orphan*/ sw_puts(char *);
int sw_strcmp(char *, char *);
int sw_strtoul(char *, void *, int);
int /*<<< orphan*/ sw_uartdbg_nofifo_init();
int strtest(int argc, char *argv[]) {
  int ret;
  char buf[128];
  sw_uartdbg_nofifo_init();
  sw_puts("----------------------");
  sw_puts("\n\r");
  sw_puts("fand compare fan: ");
  ret = sw_strcmp("fand", "fan");
  sw_putchar(ret | 0x30);
  sw_puts("\n\r");
  sw_puts("fan compare li: ");
  ret = sw_strcmp("fan", "li");
  sw_putchar(ret | 0x30);
  sw_puts("\n\r");
  sw_puts("li compare fan: ");
  ret = sw_strcmp("li", "fan");
  sw_putchar(ret | 0x30);
  sw_puts("\n\r");
  for (;;) {
    sw_getn(buf, 128);
    sw_printf("\n\r");
    ret = sw_strtoul(buf, ((void *)0), 16);
    sw_printf("[%s] = %u\n\r", buf, ret);
  }
  return 0;
}


x86 assembly (clang, -O0):
<strtest>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <sw_uartdbg_nofifo_init@plt>
lea    0xe70(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xec5(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xe6f(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xe76(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1080 <sw_strcmp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
or     $0x30,%edi
call   1030 <sw_putchar@plt>
lea    0xe8c(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xe52(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xe42(%rip),%rdi
lea    0xe50(%rip),%rsi
call   1080 <sw_strcmp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
or     $0x30,%edi
call   1030 <sw_putchar@plt>
lea    0xe53(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xe2d(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xe1e(%rip),%rdi
lea    0xe02(%rip),%rsi
call   1080 <sw_strcmp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
or     $0x30,%edi
call   1030 <sw_putchar@plt>
lea    0xe1a(%rip),%rdi
call   1040 <sw_puts@plt>
lea    -0xa0(%rbp),%rdi
mov    $0x80,%esi
call   1050 <sw_getn@plt>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1070 <sw_printf@plt>
lea    -0xa0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1090 <sw_strtoul@plt>
mov    %eax,-0x14(%rbp)
lea    -0xa0(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1070 <sw_printf@plt>
jmp    124c <strtest+0xdc>

x86 assembly (clang, -O2):
<strtest>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
xor    %eax,%eax
call   1060 <sw_uartdbg_nofifo_init@plt>
lea    0xe76(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xecb(%rip),%r15
mov    %r15,%rdi
call   1040 <sw_puts@plt>
lea    0xe72(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xe79(%rip),%rdi
lea    0xe77(%rip),%r14
mov    %r14,%rsi
call   1080 <sw_strcmp@plt>
or     $0x30,%eax
mov    %eax,%edi
call   1030 <sw_putchar@plt>
mov    %r15,%rdi
call   1040 <sw_puts@plt>
lea    0xe5a(%rip),%rdi
call   1040 <sw_puts@plt>
lea    0xe5f(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <sw_strcmp@plt>
or     $0x30,%eax
mov    %eax,%edi
call   1030 <sw_putchar@plt>
mov    %r15,%rdi
call   1040 <sw_puts@plt>
lea    0xe3e(%rip),%rdi
call   1040 <sw_puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <sw_strcmp@plt>
or     $0x30,%eax
mov    %eax,%edi
call   1030 <sw_putchar@plt>
mov    %r15,%rdi
call   1040 <sw_puts@plt>
mov    %rsp,%rbx
lea    0xe23(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    $0x80,%esi
call   1050 <sw_getn@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <sw_printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <sw_strtoul@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <sw_printf@plt>
jmp    1240 <strtest+0xd0>

LLVM IR (-O0):
@.str = [23 x i8] c"----------------------\00"
@.str.1 = [3 x i8] c"\0A\0D\00"
@.str.2 = [19 x i8] c"fand compare fan: \00"
@.str.3 = [5 x i8] c"fand\00"
@.str.4 = [4 x i8] c"fan\00"
@.str.5 = [17 x i8] c"fan compare li: \00"
@.str.6 = [3 x i8] c"li\00"
@.str.7 = [17 x i8] c"li compare fan: \00"
@.str.8 = [12 x i8] c"[%s] = %u\0A\0D\00"
define i32 @strtest(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [128 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i32 (...) @sw_uartdbg_nofifo_init()
%8 = call i32 @sw_puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @sw_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @sw_puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @sw_strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = or i32 %12, 48
%14 = call i32 @sw_putchar(i32 %13)
%15 = call i32 @sw_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @sw_puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @sw_strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = or i32 %18, 48
%20 = call i32 @sw_putchar(i32 %19)
%21 = call i32 @sw_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @sw_puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 @sw_strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = or i32 %24, 48
%26 = call i32 @sw_putchar(i32 %25)
%27 = call i32 @sw_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %28, %2
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%30 = call i32 @sw_getn(i8* %29, i32 128)
%31 = call i32 (i8*, ...) @sw_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%33 = call i32 @sw_strtoul(i8* %32, i8* null, i32 16)
store i32 %33, i32* %5
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @sw_printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %34, i32 %35)
br label %28
}

LLVM IR (-O2):
@.str = [23 x i8] c"----------------------\00"
@.str.1 = [3 x i8] c"\0A\0D\00"
@.str.2 = [19 x i8] c"fand compare fan: \00"
@.str.3 = [5 x i8] c"fand\00"
@.str.4 = [4 x i8] c"fan\00"
@.str.5 = [17 x i8] c"fan compare li: \00"
@.str.6 = [3 x i8] c"li\00"
@.str.7 = [17 x i8] c"li compare fan: \00"
@.str.8 = [12 x i8] c"[%s] = %u\0A\0D\00"
define i32 @strtest(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @sw_uartdbg_nofifo_init()
%6 = tail call i32 @sw_puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @sw_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @sw_puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @sw_strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%10 = or i32 %9, 48
%11 = tail call i32 @sw_putchar(i32 %10)
%12 = tail call i32 @sw_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @sw_puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%14 = tail call i32 @sw_strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%15 = or i32 %14, 48
%16 = tail call i32 @sw_putchar(i32 %15)
%17 = tail call i32 @sw_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @sw_puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%19 = tail call i32 @sw_strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%20 = or i32 %19, 48
%21 = tail call i32 @sw_putchar(i32 %20)
%22 = tail call i32 @sw_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %23, %2
%24 = call i32 @sw_getn(i8* %4, i32 128)
%25 = call i32 (i8*, ...) @sw_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @sw_strtoul(i8* %4, i8* null, i32 16)
%27 = call i32 (i8*, ...) @sw_printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %4, i32 %26)
br label %23
}