#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*/ new_form;

/* Variables and functions */
int bin_pos(char *);
scalar_t__ malloc(int);
int strlen(char *);
char *second_half(char *form) {
  int binary_operator = bin_pos(form);
  char new_form[strlen(form) - binary_operator];
  char *new_str2 = (char *)malloc(sizeof(new_form));
  for (int i = binary_operator + 1; i < strlen(form) - 1; i++) {
    new_str2[i - (binary_operator + 1)] = form[i];
  }
  return new_str2;
}


x86 assembly (clang, -O0):
<second_half>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <bin_pos@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    -0xc(%rbp),%eax
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11c2 <second_half+0x92>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    -0xc(%rbp),%esi
add    $0x1,%esi
sub    %esi,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1175 <second_half+0x45>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<second_half>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1040 <bin_pos@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
sub    %ebp,%eax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
add    $0x1,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cmp    %eax,%ebp
jge    1191 <second_half+0x61>
movslq %ebp,%rbp
mov    %r14,%rbx
nopl   (%rax)
movzbl (%r15,%rbp,1),%eax
mov    %al,(%rbx)
add    $0x1,%rbp
mov    %r15,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
add    $0x1,%rbx
cmp    %rax,%rbp
jl     1170 <second_half+0x40>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @second_half(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @bin_pos(i8* %8)
store i32 %9, i32* %3
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = load i32, i32* %3
%13 = sub nsw i32 %11, %12
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %4
%16 = alloca i8, i64 %14
store i64 %14, i64* %5
%17 = trunc i64 %14 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %6
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %22
22: ; preds = %41, %1
%23 = load i32, i32* %7
%24 = load i8*, i8** %2
%25 = call i32 @strlen(i8* %24)
%26 = sub nsw i32 %25, 1
%27 = icmp slt i32 %23, %26
br i1 %27, label %28, label %44
28: ; preds = %22
%29 = load i8*, i8** %2
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %6
%35 = load i32, i32* %7
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
%38 = sub nsw i32 %35, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %34, i64 %39
store i8 %33, i8* %40
br label %41
41: ; preds = %28
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %22
44: ; preds = %22
%45 = load i8*, i8** %6
%46 = load i8*, i8** %4
ret i8* %45
}

LLVM IR (-O2):
define i8* @second_half(i8* %0) {
%2 = tail call i32 @bin_pos(i8* %0)
%3 = tail call i32 @strlen(i8* %0)
%4 = sub nsw i32 %3, %2
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = add i32 %2, 1
%8 = tail call i32 @strlen(i8* %0)
%9 = add nsw i32 %8, -1
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = sext i32 %7 to i64
br label %14
13: ; preds = %14, %1
ret i8* %6
14: ; preds = %11, %14
%15 = phi i64 [ %12, %11 ], [ %20, %14 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = sub nsw i64 %15, %12
%19 = getelementptr inbounds i8, i8* %6, i64 %18
store i8 %17, i8* %19
%20 = add nsw i64 %15, 1
%21 = tail call i32 @strlen(i8* %0)
%22 = add nsw i32 %21, -1
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %20, %23
br i1 %24, label %14, label %13
}