#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*/ strcmp(char const *, char *);
int /*<<< orphan*/ strlen(char const *);
char *strrchr(char const *, char);
int source_looks_good(const char *file) {
  char *pc = NULL;
  if (!file || !strlen(file)) {
    return (0);
  }
  if (!strcmp(file, "stdin") || !strcmp(file, "-")) {
    return (1);
  }
  pc = strrchr(file, '.');
  if (!strcmp(pc + 1, "lz")) {
    return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<source_looks_good>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1161 <source_looks_good+0x31>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    116d <source_looks_good+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    11ed <source_looks_good+0xbd>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     119f <source_looks_good+0x6f>
mov    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ab <source_looks_good+0x7b>
movl   $0x1,-0x4(%rbp)
jmp    11ed <source_looks_good+0xbd>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xe3c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11e6 <source_looks_good+0xb6>
movl   $0x1,-0x4(%rbp)
jmp    11ed <source_looks_good+0xbd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<source_looks_good>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1196 <source_looks_good+0x66>
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
je     1196 <source_looks_good+0x66>
lea    0xeb3(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     1196 <source_looks_good+0x66>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1196 <source_looks_good+0x66>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%rdi
lea    0xe7f(%rip),%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"stdin\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"lz\00"
define i32 @source_looks_good(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* null, i8** %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7, %1
store i32 0, i32* %2
br label %30
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %16, %12
store i32 1, i32* %2
br label %30
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = call i8* @strrchr(i8* %22, i8 signext 46)
store i8* %23, i8** %4
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %21
store i32 1, i32* %2
br label %30
29: ; preds = %21
store i32 0, i32* %2
br label %30
30: ; preds = %29, %28, %20, %11
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [6 x i8] c"stdin\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"lz\00"
define i32 @source_looks_good(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = tail call i8* @strrchr(i8* %0, i8 signext 46)
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = tail call i32 @strcmp(i8* %14, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %12, %6, %9, %1, %3
%19 = phi i32 [ 0, %3 ], [ 0, %1 ], [ 1, %9 ], [ 1, %6 ], [ %17, %12 ]
ret i32 %19
}