#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*/ fgets(char *, int, int /*<<< orphan*/ *);
char *find_pyversions_str(char *);
char *strdup(char *);
char *find_pyversions(FILE *input) {
  char buf[4096];
  char *pyversions = NULL;
  int i;
  for (i = 0; i < 2; i++) {
    if (!fgets(buf, 4096, input)) {
      break;
    }
    if ((pyversions = find_pyversions_str(buf))) {
      break;
    }
  }
  if (pyversions) {
    return strdup(pyversions);
  } else {
    return NULL;
  }
}


x86 assembly (clang, -O0):
<find_pyversions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x1018(%rbp)
movl   $0x0,-0x101c(%rbp)
cmpl   $0x2,-0x101c(%rbp)
jge    11bf <find_pyversions+0x8f>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1000,%esi
call   1030 <fgets@plt>
cmp    $0x0,%eax
jne    1184 <find_pyversions+0x54>
jmp    11bf <find_pyversions+0x8f>
lea    -0x1010(%rbp),%rdi
call   1050 <find_pyversions_str@plt>
mov    %rax,-0x1018(%rbp)
cmp    $0x0,%rax
je     11a6 <find_pyversions+0x76>
jmp    11bf <find_pyversions+0x8f>
jmp    11ab <find_pyversions+0x7b>
mov    -0x101c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x101c(%rbp)
jmp    1154 <find_pyversions+0x24>
cmpq   $0x0,-0x1018(%rbp)
je     11e2 <find_pyversions+0xb2>
mov    -0x1018(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11ea <find_pyversions+0xba>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_pyversions>:
push   %rbx
sub    $0x1000,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
test   %eax,%eax
je     1187 <find_pyversions+0x57>
mov    %rsp,%rdi
call   1050 <find_pyversions_str@plt>
test   %rax,%rax
je     1166 <find_pyversions+0x36>
mov    %rax,%rdi
call   1040 <strdup@plt>
jmp    1189 <find_pyversions+0x59>
mov    %rsp,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
test   %eax,%eax
je     1187 <find_pyversions+0x57>
mov    %rsp,%rdi
call   1050 <find_pyversions_str@plt>
test   %rax,%rax
jne    115c <find_pyversions+0x2c>
xor    %eax,%eax
add    $0x1000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i8* @find_pyversions(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [4096 x i8]
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %3
store i8* null, i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %22, %1
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i32 @fgets(i8* %11, i32 4096, i32* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %10
br label %25
16: ; preds = %10
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%18 = call i8* @find_pyversions_str(i8* %17)
store i8* %18, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %16
br label %25
21: ; preds = %16
br label %22
22: ; preds = %21
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %7
25: ; preds = %20, %15, %7
%26 = load i8*, i8** %5
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i8*, i8** %5
%30 = call i8* @strdup(i8* %29)
store i8* %30, i8** %2
br label %32
31: ; preds = %25
store i8* null, i8** %2
br label %32
32: ; preds = %31, %28
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
define noalias i8* @find_pyversions(i32* nocapture %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = call i32 @fgets(i8* %3, i32 4096, i32* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %18, label %12
6: ; preds = %12
%7 = call i32 @fgets(i8* %3, i32 4096, i32* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = call i8* @find_pyversions_str(i8* %3)
%11 = icmp eq i8* %10, null
br i1 %11, label %18, label %15
12: ; preds = %1
%13 = call i8* @find_pyversions_str(i8* %3)
%14 = icmp eq i8* %13, null
br i1 %14, label %6, label %15
15: ; preds = %9, %12
%16 = phi i8* [ %13, %12 ], [ %10, %9 ]
%17 = call i8* @strdup(i8* %16)
br label %18
18: ; preds = %1, %6, %9, %15
%19 = phi i8* [ %17, %15 ], [ null, %9 ], [ null, %6 ], [ null, %1 ]
ret i8* %19
}