#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*/ colorize(char *, ...);
int get_single_quiet(char *);
int /*<<< orphan*/ get_string(char *, int, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ system(char *);
void blockhost(void) {
  char bl_host[51];
  char blockhost[125];
  colorize("@YHostname or IP to block (blank to quit): @G");
  get_string("", 51, bl_host, -1);
  if (strlen(bl_host) == 0) {
    colorize("@YCancel.\n@G");
  } else {
    printf("Are you sure you want to block %s(Y/n)? ", bl_host);
    switch (get_single_quiet("YyNn\n")) {
    case 'Y':
      printf("\n");
      sprintf(blockhost, "/home/bbs/bin/blockip.sh %s", bl_host);
      system(blockhost);
      colorize("@R\n%s blocked\n@G", bl_host);
      break;
    case 'N':
      colorize("@RCanceled.\n");
      break;
    case 'n':
      colorize("@RCanceled.\n");
      break;
    default:
      colorize("@RCanceled.\n");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<blockhost>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1080 <colorize@plt>
lea    -0x40(%rbp),%rdx
lea    0xf0f(%rip),%rdi
mov    $0x33,%esi
mov    $0xffffffff,%ecx
call   1040 <get_string@plt>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    11c9 <blockhost+0x59>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1080 <colorize@plt>
jmp    12a6 <blockhost+0x136>
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
lea    -0x40(%rbp),%rsi
call   1060 <printf@plt>
lea    0xe82(%rip),%rdi
call   1070 <get_single_quiet@plt>
mov    %eax,%ecx
mov    %ecx,-0xc4(%rbp)
sub    $0x4e,%eax
je     126d <blockhost+0xfd>
jmp    11fd <blockhost+0x8d>
mov    -0xc4(%rbp),%eax
sub    $0x59,%eax
je     1225 <blockhost+0xb5>
jmp    1211 <blockhost+0xa1>
mov    -0xc4(%rbp),%eax
sub    $0x6e,%eax
je     1280 <blockhost+0x110>
jmp    1293 <blockhost+0x123>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xe25(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0xc0(%rbp),%rdi
call   1050 <system@plt>
lea    -0x40(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1080 <colorize@plt>
jmp    12a1 <blockhost+0x131>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1080 <colorize@plt>
jmp    12a1 <blockhost+0x131>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1080 <colorize@plt>
jmp    12a1 <blockhost+0x131>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1080 <colorize@plt>
jmp    12a6 <blockhost+0x136>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blockhost>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1080 <colorize@plt>
lea    0xf14(%rip),%rdi
mov    %rsp,%rdx
mov    $0x33,%esi
mov    $0xffffffff,%ecx
call   1040 <get_string@plt>
cmpb   $0x0,(%rsp)
je     121b <blockhost+0xab>
lea    0xe8d(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea5(%rip),%rdi
call   1070 <get_single_quiet@plt>
cmp    $0x4e,%eax
je     1212 <blockhost+0xa2>
cmp    $0x6e,%eax
je     1212 <blockhost+0xa2>
cmp    $0x59,%eax
jne    1212 <blockhost+0xa2>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe86(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
lea    0xe80(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <colorize@plt>
jmp    1229 <blockhost+0xb9>
lea    0xe7e(%rip),%rdi
jmp    1222 <blockhost+0xb2>
lea    0xe0c(%rip),%rdi
xor    %eax,%eax
call   1080 <colorize@plt>
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [46 x i8] c"@YHostname or IP to block (blank to quit): @G\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [13 x i8] c"@YCancel.\0A@G\00"
@.str.3 = [41 x i8] c"Are you sure you want to block %s(Y/n)? \00"
@.str.4 = [6 x i8] c"YyNn\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [28 x i8] c"/home/bbs/bin/blockip.sh %s\00"
@.str.7 = [17 x i8] c"@R\0A%s blocked\0A@G\00"
@.str.8 = [13 x i8] c"@RCanceled.\0A\00"
define void @blockhost() {
%1 = alloca [51 x i8]
%2 = alloca [125 x i8]
%3 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%5 = call i32 @get_string(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 51, i8* %4, i32 -1)
%6 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%7 = call i64 @strlen(i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %31
11: ; preds = %0
%12 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = call i32 @get_single_quiet(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
switch i32 %14, label %28 [
i32 89, label %15
i32 78, label %24
i32 110, label %26
]
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%17 = getelementptr inbounds [125 x i8], [125 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [125 x i8], [125 x i8]* %2, i64 0, i64 0
%21 = call i32 @system(i8* %20)
%22 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%23 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %22)
br label %30
24: ; preds = %11
%25 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %30
26: ; preds = %11
%27 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %30
28: ; preds = %11
%29 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %30
30: ; preds = %28, %26, %24, %15
br label %31
31: ; preds = %30, %9
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"@YHostname or IP to block (blank to quit): @G\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [13 x i8] c"@YCancel.\0A@G\00"
@.str.3 = [41 x i8] c"Are you sure you want to block %s(Y/n)? \00"
@.str.4 = [6 x i8] c"YyNn\0A\00"
@.str.6 = [28 x i8] c"/home/bbs/bin/blockip.sh %s\00"
@.str.7 = [17 x i8] c"@R\0A%s blocked\0A@G\00"
@.str.8 = [13 x i8] c"@RCanceled.\0A\00"
define void @blockhost() {
%1 = alloca [51 x i8]
%2 = alloca [125 x i8]
%3 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [125 x i8], [125 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @get_string(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 51, i8* %3, i32 -1)
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %25
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%13 = call i32 @get_single_quiet(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
switch i32 %13, label %23 [
i32 89, label %14
i32 78, label %19
i32 110, label %21
]
14: ; preds = %11
%15 = call i32 @putchar(i32 10)
%16 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%17 = call i32 @system(i8* %4)
%18 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %3)
br label %25
19: ; preds = %11
%20 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %25
21: ; preds = %11
%22 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %25
23: ; preds = %11
%24 = call i32 (i8*, ...) @colorize(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %25
25: ; preds = %14, %19, %21, %23, %9
ret void
}