#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ asprintf(char **, char *, char const *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
scalar_t__ strcmp(char const *, char *);
int md5_check(const char *right, const char *where) {
  char *def, buf[33];
  asprintf(&def, "wget --timeout=2 -t2 -q -O- %s | md5sum -", where);
  FILE *f = popen(def, "r");
  if (!f)
    return 0;
  fgets(buf, 33, f);
  free(def);
  pclose(f);
  return (strcmp(right, buf) == 0);
}


x86 assembly (clang, -O0):
<md5_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1070 <asprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    11af <md5_check+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    11ef <md5_check+0x8f>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rdx
mov    $0x21,%esi
call   1050 <fgets@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5_check>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rdx
mov    %rdi,%r14
lea    0xe8a(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1070 <asprintf@plt>
mov    0x8(%rsp),%rdi
lea    0xe9e(%rip),%rsi
call   1080 <popen@plt>
test   %rax,%rax
je     11d8 <md5_check+0x78>
mov    %rax,%rbx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x21,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1040 <pclose@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
jmp    11da <md5_check+0x7a>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"wget --timeout=2 -t2 -q -O- %s | md5sum -\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @md5_check(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [33 x i8]
%8 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @asprintf(i8** %6, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %6
%12 = call i32* @popen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %8
%13 = load i32*, i32** %8
%14 = icmp ne i32* %13, null
br i1 %14, label %16, label %15
15: ; preds = %2
store i32 0, i32* %3
br label %29
16: ; preds = %2
%17 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%18 = load i32*, i32** %8
%19 = call i32 @fgets(i8* %17, i32 33, i32* %18)
%20 = load i8*, i8** %6
%21 = call i32 @free(i8* %20)
%22 = load i32*, i32** %8
%23 = call i32 @pclose(i32* %22)
%24 = load i8*, i8** %4
%25 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%26 = call i64 @strcmp(i8* %24, i8* %25)
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
store i32 %28, i32* %3
br label %29
29: ; preds = %16, %15
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [42 x i8] c"wget --timeout=2 -t2 -q -O- %s | md5sum -\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @md5_check(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca [33 x i8]
%5 = bitcast i8** %3 to i8*
%6 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%7 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %1)
%8 = load i8*, i8** %3
%9 = call i32* @popen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %19, label %11
11: ; preds = %2
%12 = call i32 @fgets(i8* %6, i32 33, i32* %9)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
%15 = call i32 @pclose(i32* %9)
%16 = call i64 @strcmp(i8* %0, i8* %6)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %2, %11
%20 = phi i32 [ %18, %11 ], [ 0, %2 ]
ret i32 %20
}