#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 */
struct aggent {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
scalar_t__ newfunction(char *);
int printblock(int /*<<< orphan*/ *, struct aggent *);
int strlen(char *);
int general_printc(FILE *fp, struct aggent *agg) {
  char buffer[161];
  while (fgets(buffer, 161, fp) != NULL) {
    fseek(fp, strlen(buffer) * -1, SEEK_CUR);
    if (newfunction(buffer) != 0)
      break;
    if (printblock(fp, agg) == -1)
      return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<general_printc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0xc0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xa1,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11f3 <general_printc+0xa3>
mov    -0x10(%rbp),%rax
mov    %rax,-0xc8(%rbp)
lea    -0xc0(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xc8(%rbp),%rdi
imul   $0xffffffff,%eax,%esi
mov    0x2e3e(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
lea    -0xc0(%rbp),%rdi
call   1060 <newfunction@plt>
cmp    $0x0,%rax
je     11cc <general_printc+0x7c>
jmp    11f3 <general_printc+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <printblock@plt>
cmp    $0xffffffff,%eax
jne    11ee <general_printc+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fa <general_printc+0xaa>
jmp    1163 <general_printc+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<general_printc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb0,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    0x2e79(%rip),%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0xa1,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11cf <general_printc+0x7f>
mov    %r15,%rdi
call   1030 <strlen@plt>
neg    %eax
mov    (%r12),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <fseek@plt>
mov    %r15,%rdi
call   1060 <newfunction@plt>
test   %rax,%rax
jne    11cf <general_printc+0x7f>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <printblock@plt>
cmp    $0xffffffff,%eax
jne    1180 <general_printc+0x30>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.aggent = type { i32 }
@SEEK_CUR = global i32 0
define i32 @general_printc(i32* %0, %struct.aggent* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca %struct.aggent*
%6 = alloca [161 x i8]
store i32* %0, i32** %4
store %struct.aggent* %1, %struct.aggent** %5
br label %7
7: ; preds = %29, %2
%8 = getelementptr inbounds [161 x i8], [161 x i8]* %6, i64 0, i64 0
%9 = load i32*, i32** %4
%10 = call i32* @fgets(i8* %8, i32 161, i32* %9)
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %30
12: ; preds = %7
%13 = load i32*, i32** %4
%14 = getelementptr inbounds [161 x i8], [161 x i8]* %6, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = mul nsw i32 %15, -1
%17 = load i32, i32* @SEEK_CUR
%18 = call i32 @fseek(i32* %13, i32 %16, i32 %17)
%19 = getelementptr inbounds [161 x i8], [161 x i8]* %6, i64 0, i64 0
%20 = call i64 @newfunction(i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %12
br label %30
23: ; preds = %12
%24 = load i32*, i32** %4
%25 = load %struct.aggent*, %struct.aggent** %5
%26 = call i32 @printblock(i32* %24, %struct.aggent* %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 -1, i32* %3
br label %31
29: ; preds = %23
br label %7
30: ; preds = %22, %7
store i32 0, i32* %3
br label %31
31: ; preds = %30, %28
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
%struct.aggent = type { i32 }
@SEEK_CUR = global i32 0
define i32 @general_printc(i32* %0, %struct.aggent* %1) {
%3 = alloca [161 x i8]
%4 = getelementptr inbounds [161 x i8], [161 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %15, %2
%6 = call i32* @fgets(i8* %4, i32 161, i32* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %18, label %8
8: ; preds = %5
%9 = call i32 @strlen(i8* %4)
%10 = sub nsw i32 0, %9
%11 = load i32, i32* @SEEK_CUR
%12 = call i32 @fseek(i32* %0, i32 %10, i32 %11)
%13 = call i64 @newfunction(i8* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = call i32 @printblock(i32* %0, %struct.aggent* %1)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %5
18: ; preds = %5, %8, %15
%19 = phi i32 [ -1, %15 ], [ 0, %8 ], [ 0, %5 ]
ret i32 %19
}