#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 memset(char *, char, unsigned int);
int pgopen_(char *, size_t);
unsigned int strlen(char *);
int __cf__PGOPEN(char *A1, unsigned C1) {
  struct {
    unsigned int clen, flen;
    char *nombre;
  } B1;
  int A0;
  (B1.nombre = A1, B1.clen = strlen(A1),
   C1 == sizeof(char *) || C1 == (unsigned)(B1.clen + 1)
       ? B1.flen = B1.clen
       : (memset(B1.nombre + B1.clen, ' ', C1 - B1.clen - 1),
          B1.nombre[B1.flen = C1 - 1] = '\0'));
  A0 = pgopen_(A1, B1.flen);
  (B1.nombre = A1, B1.nombre[B1.clen] != '\0' ? B1.nombre[B1.clen] = '\0' : 0);
  return A0;
}


x86 assembly (clang, -O0):
<__cf__PGOPEN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cmp    $0x8,%rax
je     1171 <__cf__PGOPEN+0x41>
mov    -0xc(%rbp),%eax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    117c <__cf__PGOPEN+0x4c>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <__cf__PGOPEN+0x7c>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%eax
add    %rax,%rdi
mov    -0xc(%rbp),%edx
sub    -0x20(%rbp),%edx
sub    $0x1,%edx
mov    $0x20,%esi
call   1050 <memset@plt>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    %eax,%esi
call   1030 <pgopen_@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11e9 <__cf__PGOPEN+0xb9>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
jmp    11ee <__cf__PGOPEN+0xbe>
jmp    11ee <__cf__PGOPEN+0xbe>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__cf__PGOPEN>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r15,%rsi
cmp    $0x8,%ebx
je     1174 <__cf__PGOPEN+0x44>
add    $0x1,%eax
mov    %r15,%rsi
cmp    %ebx,%eax
je     1174 <__cf__PGOPEN+0x44>
lea    (%r14,%r15,1),%rdi
mov    %r15d,%edx
not    %edx
add    %ebx,%edx
mov    $0x20,%esi
call   1050 <memset@plt>
add    $0xffffffff,%ebx
movb   $0x0,(%r14,%rbx,1)
mov    %rbx,%rsi
mov    %r14,%rdi
call   1030 <pgopen_@plt>
cmpb   $0x0,(%r14,%r15,1)
je     1188 <__cf__PGOPEN+0x58>
movb   $0x0,(%r14,%r15,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.anon = type { i32, i32, i8* }
define i32 @__cf__PGOPEN(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.anon
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 2
store i8* %7, i8** %8
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
store i32 %10, i32* %11
%12 = load i32, i32* %4
%13 = zext i32 %12 to i64
%14 = icmp eq i64 %13, 8
br i1 %14, label %21, label %15
15: ; preds = %2
%16 = load i32, i32* %4
%17 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%18 = load i32, i32* %17
%19 = add i32 %18, 1
%20 = icmp eq i32 %16, %19
br i1 %20, label %21, label %25
21: ; preds = %15, %2
%22 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 1
store i32 %23, i32* %24
br label %45
25: ; preds = %15
%26 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 2
%27 = load i8*, i8** %26
%28 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%29 = load i32, i32* %28
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = load i32, i32* %4
%33 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%34 = load i32, i32* %33
%35 = sub i32 %32, %34
%36 = sub i32 %35, 1
%37 = call i32 @memset(i8* %31, i8 signext 32, i32 %36)
%38 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 2
%39 = load i8*, i8** %38
%40 = load i32, i32* %4
%41 = sub i32 %40, 1
%42 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 1
store i32 %41, i32* %42
%43 = zext i32 %41 to i64
%44 = getelementptr inbounds i8, i8* %39, i64 %43
store i8 0, i8* %44
br label %45
45: ; preds = %25, %21
%46 = phi i32 [ %23, %21 ], [ 0, %25 ]
%47 = load i8*, i8** %3
%48 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 1
%49 = load i32, i32* %48
%50 = zext i32 %49 to i64
%51 = call i32 @pgopen_(i8* %47, i64 %50)
store i32 %51, i32* %6
%52 = load i8*, i8** %3
%53 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 2
store i8* %52, i8** %53
%54 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 2
%55 = load i8*, i8** %54
%56 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%57 = load i32, i32* %56
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %55, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %70
63: ; preds = %45
%64 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 2
%65 = load i8*, i8** %64
%66 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%67 = load i32, i32* %66
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %65, i64 %68
store i8 0, i8* %69
br label %71
70: ; preds = %45
br label %71
71: ; preds = %70, %63
%72 = phi i32 [ 0, %63 ], [ 0, %70 ]
%73 = load i32, i32* %6
ret i32 %73
}

LLVM IR (-O2):
define i32 @__cf__PGOPEN(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i32 %1, 8
%5 = add i32 %3, 1
%6 = icmp eq i32 %5, %1
%7 = select i1 %4, i1 true, i1 %6
%8 = zext i32 %3 to i64
br i1 %7, label %17, label %9
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %0, i64 %8
%11 = xor i32 %3, -1
%12 = add i32 %11, %1
%13 = tail call i32 @memset(i8* %10, i8 signext 32, i32 %12)
%14 = add i32 %1, -1
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
store i8 0, i8* %16
br label %17
17: ; preds = %2, %9
%18 = phi i64 [ %15, %9 ], [ %8, %2 ]
%19 = tail call i32 @pgopen_(i8* %0, i64 %18)
%20 = getelementptr inbounds i8, i8* %0, i64 %8
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %17
store i8 0, i8* %20
br label %24
24: ; preds = %17, %23
ret i32 %19
}