#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 */
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ strstr(char *, char *);
int check_wget_ok(char *logfile) {
  FILE *ccfp = NULL;
  char buf[254];
  int success = 0;
  if ((ccfp = fopen(logfile, "r"))) {
    while (fgets(buf, sizeof(buf), ccfp) != NULL) {
      if (strstr(buf, "100%")) {
        success = 1;
        break;
      }
    }
    fclose(ccfp);
  }
  return success;
}


x86 assembly (clang, -O0):
<check_wget_ok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x114(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11dd <check_wget_ok+0x9d>
jmp    1184 <check_wget_ok+0x44>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xfe,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11d4 <check_wget_ok+0x94>
lea    -0x110(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11cf <check_wget_ok+0x8f>
movl   $0x1,-0x114(%rbp)
jmp    11d4 <check_wget_ok+0x94>
jmp    1184 <check_wget_ok+0x44>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x114(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_wget_ok>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     119c <check_wget_ok+0x5c>
mov    %rax,%r14
mov    %rsp,%rbx
lea    0xe98(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0xfe,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11a0 <check_wget_ok+0x60>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1170 <check_wget_ok+0x30>
mov    $0x1,%ebx
jmp    11a2 <check_wget_ok+0x62>
xor    %ebx,%ebx
jmp    11aa <check_wget_ok+0x6a>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %ebx,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"100%\00"
define i32 @check_wget_ok(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [254 x i8]
%5 = alloca i32
store i8* %0, i8** %2
store i32* null, i32** %3
store i32 0, i32* %5
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %24
9: ; preds = %1
br label %10
10: ; preds = %20, %9
%11 = getelementptr inbounds [254 x i8], [254 x i8]* %4, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i32* @fgets(i8* %11, i32 254, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = getelementptr inbounds [254 x i8], [254 x i8]* %4, i64 0, i64 0
%17 = call i64 @strstr(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 1, i32* %5
br label %21
20: ; preds = %15
br label %10
21: ; preds = %19, %10
%22 = load i32*, i32** %3
%23 = call i32 @fclose(i32* %22)
br label %24
24: ; preds = %21, %1
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"100%\00"
define i32 @check_wget_ok(i8* nocapture %0) {
%2 = alloca [254 x i8]
%3 = getelementptr inbounds [254 x i8], [254 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %15, label %6
6: ; preds = %1, %9
%7 = call i32* @fgets(i8* %3, i32 254, i32* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = call i64 @strstr(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %9, %6
%13 = phi i32 [ 0, %6 ], [ 1, %9 ]
%14 = call i32 @fclose(i32* %4)
br label %15
15: ; preds = %12, %1
%16 = phi i32 [ %13, %12 ], [ 0, %1 ]
ret i32 %16
}