#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 /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
char *returner(char *);
int /*<<< orphan*/ stdin;
int main(void) {
  char *s = malloc(500), *sptr;
  while (fgets(s, 500, stdin) != NULL) {
    sptr = returner(s);
    printf("Pointer address = [%p]\n", sptr);
    printf("Pointer[0] = [%c], Pointer[1] = [%c], Pointer[2] = [%c]\n", sptr[0],
           sptr[1], sptr[2]);
    printf("Full string of pointer address = [%s]\n", sptr);
  }
  free(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1f4,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    $0x1f4,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11e9 <main+0x99>
mov    -0x10(%rbp),%rdi
call   1070 <returner@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%edx
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%ecx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    116d <main+0x1d>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1f4,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    0x2e79(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rax,%rdi
mov    $0x1f4,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11ef <main+0x9f>
lea    0xe75(%rip),%r14
lea    0xe86(%rip),%r15
lea    0xeb8(%rip),%r12
nopl   0x0(%rax)
mov    %r13,%rdi
call   1070 <returner@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl (%rbx),%esi
movsbl 0x1(%rbx),%edx
movsbl 0x2(%rbx),%ecx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%rbp),%edx
mov    %r13,%rdi
mov    $0x1f4,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    11a0 <main+0x50>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [24 x i8] c"Pointer address = [%p]\0A\00"
@.str.1 = [57 x i8] c"Pointer[0] = [%c], Pointer[1] = [%c], Pointer[2] = [%c]\0A\00"
@.str.2 = [39 x i8] c"Full string of pointer address = [%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i8* @malloc(i32 500)
store i8* %4, i8** %2
br label %5
5: ; preds = %10, %0
%6 = load i8*, i8** %2
%7 = load i32, i32* @stdin
%8 = call i32* @fgets(i8* %6, i32 500, i32 %7)
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %30
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = call i8* @returner(i8* %11)
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %22, i32 %26)
%28 = load i8*, i8** %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %5
30: ; preds = %5
%31 = load i8*, i8** %2
%32 = call i32 @free(i8* %31)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [24 x i8] c"Pointer address = [%p]\0A\00"
@.str.1 = [57 x i8] c"Pointer[0] = [%c], Pointer[1] = [%c], Pointer[2] = [%c]\0A\00"
@.str.2 = [39 x i8] c"Full string of pointer address = [%s]\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(500) i8* @malloc(i32 500)
%2 = load i32, i32* @stdin
%3 = tail call i32* @fgets(i8* %1, i32 500, i32 %2)
%4 = icmp eq i32* %3, null
br i1 %4, label %21, label %5
5: ; preds = %0, %5
%6 = tail call i8* @returner(i8* %1)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8, i8* %6
%9 = sext i8 %8 to i32
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = getelementptr inbounds i8, i8* %6, i64 2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %12, i32 %15)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%18 = load i32, i32* @stdin
%19 = tail call i32* @fgets(i8* %1, i32 500, i32 %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %5
21: ; preds = %5, %0
%22 = tail call i32 @free(i8* %1)
ret i32 0
}