#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*/ free(char *);
char *getln(int /*<<< orphan*/ *);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
int uniq(FILE *in) {
  char *line = NULL, *last = NULL;
  if (!in)
    return -1;
  while ((line = getln(in))) {
    if (!last || strcmp(last, line))
      puts(line);
    free(last);
    last = line;
  }
  free(last);
  free(line);
  return 0;
}


x86 assembly (clang, -O0):
<uniq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1173 <uniq+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e9 <uniq+0xa9>
jmp    1178 <uniq+0x38>
mov    -0x10(%rbp),%rdi
call   1050 <getln@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11d0 <uniq+0x90>
cmpq   $0x0,-0x20(%rbp)
je     11b1 <uniq+0x71>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11ba <uniq+0x7a>
mov    -0x18(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1178 <uniq+0x38>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uniq>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11aa <uniq+0x6a>
mov    %rdi,%r15
call   1050 <getln@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11b2 <uniq+0x72>
xor    %ebx,%ebx
jmp    1190 <uniq+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <getln@plt>
mov    %r12,%rbx
test   %rax,%rax
je     11b5 <uniq+0x75>
mov    %rax,%r12
test   %rbx,%rbx
je     1170 <uniq+0x30>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1170 <uniq+0x30>
jmp    1178 <uniq+0x38>
mov    $0xffffffff,%r14d
jmp    11c4 <uniq+0x84>
xor    %r12d,%r12d
mov    %r12,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1030 <free@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @uniq(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
store i32* %0, i32** %3
store i8* null, i8** %4
store i8* null, i8** %5
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 -1, i32* %2
br label %34
9: ; preds = %1
br label %10
10: ; preds = %25, %9
%11 = load i32*, i32** %3
%12 = call i8* @getln(i32* %11)
store i8* %12, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i8*, i8** %5
%19 = load i8*, i8** %4
%20 = call i64 @strcmp(i8* %18, i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17, %14
%23 = load i8*, i8** %4
%24 = call i32 @puts(i8* %23)
br label %25
25: ; preds = %22, %17
%26 = load i8*, i8** %5
%27 = call i32 @free(i8* %26)
%28 = load i8*, i8** %4
store i8* %28, i8** %5
br label %10
29: ; preds = %10
%30 = load i8*, i8** %5
%31 = call i32 @free(i8* %30)
%32 = load i8*, i8** %4
%33 = call i32 @free(i8* %32)
store i32 0, i32* %2
br label %34
34: ; preds = %29, %8
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
define i32 @uniq(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %23, label %3
3: ; preds = %1
%4 = tail call i8* @getln(i32* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %19, label %6
6: ; preds = %3, %15
%7 = phi i8* [ %17, %15 ], [ %4, %3 ]
%8 = phi i8* [ %7, %15 ], [ null, %3 ]
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i64 @strcmp(i8* %8, i8* %7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10, %6
%14 = tail call i32 @puts(i8* %7)
br label %15
15: ; preds = %13, %10
%16 = tail call i32 @free(i8* %8)
%17 = tail call i8* @getln(i32* %0)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %6
19: ; preds = %15, %3
%20 = phi i8* [ null, %3 ], [ %7, %15 ]
%21 = tail call i32 @free(i8* %20)
%22 = tail call i32 @free(i8* null)
br label %23
23: ; preds = %1, %19
%24 = phi i32 [ 0, %19 ], [ -1, %1 ]
ret i32 %24
}