#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 */
scalar_t__ malloc(int);
int strlen(char *);
void take_out_ip(char *pack) {
  char *ip = (char *)malloc(20);
  int i, flag = 0, j = 0;
  for (i = strlen(pack) - 1; i >= 0; i--) {
    if (pack[i] == '|')
      break;
  }
  pack[i] = '\0';
  return;
}


x86 assembly (clang, -O0):
<take_out_ip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x14,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     118e <take_out_ip+0x6e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7c,%eax
jne    117b <take_out_ip+0x5b>
jmp    118e <take_out_ip+0x6e>
jmp    1180 <take_out_ip+0x60>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <take_out_ip+0x37>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<take_out_ip>:
push   %rbx
mov    %rdi,%rbx
mov    $0x14,%edi
call   1040 <malloc@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%edx
xor    %ecx,%ecx
test   %eax,%eax
cmovs  %eax,%ecx
add    $0xffffffff,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %edx,%edx
jle    1162 <take_out_ip+0x42>
add    $0xffffffffffffffff,%rdx
mov    %edx,%eax
cmpb   $0x7c,(%rbx,%rax,1)
jne    1150 <take_out_ip+0x30>
mov    %edx,%ecx
movslq %ecx,%rax
movb   $0x0,(%rbx,%rax,1)
pop    %rbx
ret

LLVM IR (-O0):
define void @take_out_ip(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = call i64 @malloc(i32 20)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
store i32 0, i32* %5
store i32 0, i32* %6
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %4
br label %12
12: ; preds = %25, %1
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 124
br i1 %22, label %23, label %24
23: ; preds = %15
br label %28
24: ; preds = %15
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, -1
store i32 %27, i32* %4
br label %12
28: ; preds = %23, %12
%29 = load i8*, i8** %2
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
ret void
}

LLVM IR (-O2):
define void @take_out_ip(i8* %0) {
%2 = tail call i64 @malloc(i32 20)
%3 = tail call i32 @strlen(i8* %0)
%4 = zext i32 %3 to i64
%5 = call i32 @llvm.smin.i32(i32 %3, i32 0)
%6 = add i32 %5, -1
br label %7
7: ; preds = %12, %1
%8 = phi i64 [ %9, %12 ], [ %4, %1 ]
%9 = add nsw i64 %8, -1
%10 = trunc i64 %8 to i32
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = and i64 %9, 4294967295
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 124
br i1 %16, label %17, label %7
17: ; preds = %12
%18 = trunc i64 %9 to i32
br label %19
19: ; preds = %7, %17
%20 = phi i32 [ %18, %17 ], [ %6, %7 ]
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %0, i64 %21
store i8 0, i8* %22
ret void
}