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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(int *);
int getdelim(char **, size_t *, char, int /*<<< orphan*/ *);
scalar_t__ git_release_string_utility_startswith(char *, char *);
int git_release_ssh_private_key_is_encrypted(int *out, char *private_key_path) {
  *out = 0;
  char *line;
  FILE *file;
  file = fopen(private_key_path, "r");
  size_t len = 0;
  for (int i = 0; i < 2; i++) {
    ssize_t bytes_read = getdelim(&line, &len, '\n', file);
    if (bytes_read == -1) {
      fclose(file);
      free(out);
      return 1;
    }
  }
  if (git_release_string_utility_startswith(line, "Proc-Type: 4,ENCRYPTED") ==
      0) {
    *out = 1;
  }
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<git_release_ssh_private_key_is_encrypted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x2,-0x34(%rbp)
jge    11eb <git_release_ssh_private_key_is_encrypted+0x9b>
mov    -0x28(%rbp),%rcx
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1070 <getdelim@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
jne    11d8 <git_release_ssh_private_key_is_encrypted+0x88>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    121f <git_release_ssh_private_key_is_encrypted+0xcf>
jmp    11dd <git_release_ssh_private_key_is_encrypted+0x8d>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118d <git_release_ssh_private_key_is_encrypted+0x3d>
mov    -0x20(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1050 <git_release_string_utility_startswith@plt>
cmp    $0x0,%rax
jne    120f <git_release_ssh_private_key_is_encrypted+0xbf>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<git_release_ssh_private_key_is_encrypted>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rax
mov    %rdi,%r14
movl   $0x0,(%rdi)
lea    0xe96(%rip),%rsi
mov    %rax,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
mov    %rax,%rcx
call   1070 <getdelim@plt>
cmp    $0xffffffff,%eax
je     11df <git_release_ssh_private_key_is_encrypted+0x8f>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
mov    %rbx,%rcx
call   1070 <getdelim@plt>
cmp    $0xffffffff,%eax
je     11df <git_release_ssh_private_key_is_encrypted+0x8f>
mov    0x10(%rsp),%rdi
lea    0xe40(%rip),%rsi
call   1050 <git_release_string_utility_startswith@plt>
test   %rax,%rax
jne    11d3 <git_release_ssh_private_key_is_encrypted+0x83>
movl   $0x1,(%r14)
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11f4 <git_release_ssh_private_key_is_encrypted+0xa4>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"Proc-Type: 4,ENCRYPTED\00"
define i32 @git_release_ssh_private_key_is_encrypted(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%11 = load i32*, i32** %4
store i32 0, i32* %11
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %7
store i64 0, i64* %8
store i32 0, i32* %9
br label %14
14: ; preds = %28, %2
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = load i32*, i32** %7
%19 = call i32 @getdelim(i8** %6, i64* %8, i8 signext 10, i32* %18)
store i32 %19, i32* %10
%20 = load i32, i32* %10
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i32*, i32** %7
%24 = call i32 @fclose(i32* %23)
%25 = load i32*, i32** %4
%26 = call i32 @free(i32* %25)
store i32 1, i32* %3
br label %40
27: ; preds = %17
br label %28
28: ; preds = %27
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
br label %14
31: ; preds = %14
%32 = load i8*, i8** %6
%33 = call i64 @git_release_string_utility_startswith(i8* %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = load i32*, i32** %4
store i32 1, i32* %36
br label %37
37: ; preds = %35, %31
%38 = load i32*, i32** %7
%39 = call i32 @fclose(i32* %38)
store i32 0, i32* %3
br label %40
40: ; preds = %37, %22
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"Proc-Type: 4,ENCRYPTED\00"
define i32 @git_release_ssh_private_key_is_encrypted(i32* nocapture %0, i8* nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
store i32 0, i32* %0
%5 = bitcast i8** %3 to i8*
%6 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%8 = call i32 @getdelim(i8** %3, i64* %4, i8 signext 10, i32* %6)
%9 = icmp eq i32 %8, -1
br i1 %9, label %17, label %10
10: ; preds = %2
%11 = call i32 @getdelim(i8** %3, i64* %4, i8 signext 10, i32* %6)
%12 = icmp eq i32 %11, -1
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = call i64 @git_release_string_utility_startswith(i8* %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %21
17: ; preds = %10, %2
%18 = call i32 @fclose(i32* %6)
%19 = call i32 @free(i32* %0)
br label %23
20: ; preds = %13
store i32 1, i32* %0
br label %21
21: ; preds = %20, %13
%22 = call i32 @fclose(i32* %6)
br label %23
23: ; preds = %17, %21
%24 = phi i32 [ 0, %21 ], [ 1, %17 ]
ret i32 %24
}