#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 */
scalar_t__ is_printable_str(char *);
int /*<<< orphan*/ printf(char *, ...);
void print_suspicious_str(char *name, char *str) {
  printf("%s: ", name);
  if (str == 0) {
    printf("(null)\n");
  } else if ((long int)str > -1000 && (long int)str < 1000) {
    printf("%ld\n", (long int)str);
  } else if (is_printable_str(str)) {
    printf("%s\n", str);
  } else {
    printf("[non-str]\n");
  }
}


x86 assembly (clang, -O0):
<print_suspicious_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1160 <print_suspicious_str+0x40>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d9 <print_suspicious_str+0xb9>
mov    -0x10(%rbp),%rax
cmp    $0xfffffffffffffc18,%rax
jle    1197 <print_suspicious_str+0x77>
mov    -0x10(%rbp),%rax
cmp    $0x3e8,%rax
jge    1197 <print_suspicious_str+0x77>
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d4 <print_suspicious_str+0xb4>
mov    -0x10(%rbp),%rdi
call   1030 <is_printable_str@plt>
cmp    $0x0,%rax
je     11c1 <print_suspicious_str+0xa1>
mov    -0x10(%rbp),%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11cf <print_suspicious_str+0xaf>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d4 <print_suspicious_str+0xb4>
jmp    11d9 <print_suspicious_str+0xb9>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_suspicious_str>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbx,%rbx
je     116e <print_suspicious_str+0x3e>
cmp    $0xfffffffffffffc19,%rbx
jl     117b <print_suspicious_str+0x4b>
cmp    $0x3e7,%rbx
jg     117b <print_suspicious_str+0x4b>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
pop    %rbx
jmp    1050 <printf@plt>
lea    0xe9f(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <is_printable_str@plt>
test   %rax,%rax
je     1191 <print_suspicious_str+0x61>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xe72(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [8 x i8] c"(null)\0A\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [11 x i8] c"[non-str]\0A\00"
define void @print_suspicious_str(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %34
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = ptrtoint i8* %12 to i64
%14 = icmp sgt i64 %13, -1000
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = ptrtoint i8* %16 to i64
%18 = icmp slt i64 %17, 1000
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = ptrtoint i8* %20 to i64
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %21)
br label %33
23: ; preds = %15, %11
%24 = load i8*, i8** %4
%25 = call i64 @is_printable_str(i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %32
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
br label %33
33: ; preds = %32, %19
br label %34
34: ; preds = %33, %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s: \00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@str = [10 x i8] c"[non-str]\00"
@str.5 = [7 x i8] c"(null)\00"
define void @print_suspicious_str(i8* %0, i8* %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = icmp eq i8* %1, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
br label %21
7: ; preds = %2
%8 = icmp sgt i8* %1, inttoptr (i64 -1000 to i8*)
%9 = icmp slt i8* %1, inttoptr (i64 1000 to i8*)
%10 = and i1 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = ptrtoint i8* %1 to i64
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %12)
br label %21
14: ; preds = %7
%15 = tail call i64 @is_printable_str(i8* %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @puts(i8* %1)
br label %21
19: ; preds = %14
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %11, %19, %17, %5
ret void
}