#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 nice_ugly(char *, int, int /*<<< orphan*/, int /*<<< orphan*/,
              int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
void main() {
  char str[] = "HELLOW?RLD";
  int len = strlen(str);
  int res = nice_ugly(str, len, 0, 0, 0);
  if (res == 1) {
    printf("Ugly");
  } else if (res == 0) {
    printf("Nice");
  } else {
    printf("42");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0xb(%rbp)
mov    0xebe(%rip),%ax
mov    %ax,-0x3(%rbp)
mov    0xeb6(%rip),%al
mov    %al,-0x1(%rbp)
lea    -0xb(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
lea    -0xb(%rbp),%rdi
mov    -0x10(%rbp),%esi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1050 <nice_ugly@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1196 <main+0x66>
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
jmp    11c2 <main+0x92>
cmpl   $0x0,-0x14(%rbp)
jne    11b1 <main+0x81>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
jmp    11bd <main+0x8d>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
jmp    11c2 <main+0x92>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x523f574f4c4c4548,%rax
57 3f 52
mov    %rax,(%rsp)
movl   $0x444c52,0x7(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <nice_ugly@plt>
test   %eax,%eax
lea    0xea0(%rip),%rcx
lea    0xe9e(%rip),%rdx
cmove  %rcx,%rdx
cmp    $0x1,%eax
lea    0xe86(%rip),%rdi
cmovne %rdx,%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.str = [11 x i8] c"HELLOW?RLD\00"
@.str = [5 x i8] c"Ugly\00"
@.str.1 = [5 x i8] c"Nice\00"
@.str.2 = [3 x i8] c"42\00"
define void @main() {
%1 = alloca [11 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [11 x i8]* %1 to i8*
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %2
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%8 = load i32, i32* %2
%9 = call i32 @nice_ugly(i8* %7, i32 %8, i32 0, i32 0, i32 0)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %22
14: ; preds = %0
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %21
19: ; preds = %14
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
br label %22
22: ; preds = %21, %12
ret void
}

LLVM IR (-O2):
@__const.main.str = [11 x i8] c"HELLOW?RLD\00"
@.str = [5 x i8] c"Ugly\00"
@.str.1 = [5 x i8] c"Nice\00"
@.str.2 = [3 x i8] c"42\00"
define void @main() {
%1 = alloca [11 x i8]
%2 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = call i32 @nice_ugly(i8* %2, i32 %3, i32 0, i32 0, i32 0)
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%7 = icmp eq i32 %4, 1
%8 = select i1 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6
%9 = call i32 @printf(i8* dereferenceable(1) %8)
ret void
}