#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 ft_gp(double);
int ft_pute(double, int *, char *);
int ft_putf(double, int *, char *);
int ft_putg(double n, int fl[8], char *s) {
  fl[1] = (fl[1] == -1) ? 6 : fl[1];
  fl[1] = (fl[1] == 0) ? 1 : fl[1];
  if (ft_gp(n) < -3 || ft_gp(n) >= fl[1])
    return (ft_pute(n, fl, s));
  else
    return (ft_putf(n, fl, s));
}


x86 assembly (clang, -O0):
<ft_putg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0xffffffff,0x4(%rax)
jne    1160 <ft_putg+0x30>
mov    $0x6,%eax
mov    %eax,-0x24(%rbp)
jmp    116a <ft_putg+0x3a>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jne    118f <ft_putg+0x5f>
mov    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1199 <ft_putg+0x69>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
movsd  -0x10(%rbp),%xmm0
call   1040 <ft_gp@plt>
cmp    $0xfffffffd,%eax
jl     11cd <ft_putg+0x9d>
movsd  -0x10(%rbp),%xmm0
call   1040 <ft_gp@plt>
mov    -0x18(%rbp),%rcx
cmp    0x4(%rcx),%eax
jl     11e7 <ft_putg+0xb7>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <ft_pute@plt>
mov    %eax,-0x4(%rbp)
jmp    11fc <ft_putg+0xcc>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <ft_putf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putg>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x4(%rdi),%eax
cmp    $0xffffffff,%eax
mov    $0x6,%ecx
cmovne %eax,%ecx
test   %ecx,%ecx
mov    $0x1,%eax
cmovne %ecx,%eax
mov    %eax,0x4(%rdi)
movsd  %xmm0,(%rsp)
call   1040 <ft_gp@plt>
cmp    $0xfffffffd,%eax
jl     118a <ft_putg+0x5a>
movsd  (%rsp),%xmm0
call   1040 <ft_gp@plt>
cmp    0x4(%rbx),%eax
jge    118a <ft_putg+0x5a>
movsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <ft_putf@plt>
movsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <ft_pute@plt>

LLVM IR (-O0):
define i32 @ft_putg(double %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca i32*
%7 = alloca i8*
store double %0, double* %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%8 = load i32*, i32** %6
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %3
br label %17
13: ; preds = %3
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %15
br label %17
17: ; preds = %13, %12
%18 = phi i32 [ 6, %12 ], [ %16, %13 ]
%19 = load i32*, i32** %6
%20 = getelementptr inbounds i32, i32* %19, i64 1
store i32 %18, i32* %20
%21 = load i32*, i32** %6
%22 = getelementptr inbounds i32, i32* %21, i64 1
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %17
br label %30
26: ; preds = %17
%27 = load i32*, i32** %6
%28 = getelementptr inbounds i32, i32* %27, i64 1
%29 = load i32, i32* %28
br label %30
30: ; preds = %26, %25
%31 = phi i32 [ 1, %25 ], [ %29, %26 ]
%32 = load i32*, i32** %6
%33 = getelementptr inbounds i32, i32* %32, i64 1
store i32 %31, i32* %33
%34 = load double, double* %5
%35 = call i32 @ft_gp(double %34)
%36 = icmp slt i32 %35, -3
br i1 %36, label %44, label %37
37: ; preds = %30
%38 = load double, double* %5
%39 = call i32 @ft_gp(double %38)
%40 = load i32*, i32** %6
%41 = getelementptr inbounds i32, i32* %40, i64 1
%42 = load i32, i32* %41
%43 = icmp sge i32 %39, %42
br i1 %43, label %44, label %49
44: ; preds = %37, %30
%45 = load double, double* %5
%46 = load i32*, i32** %6
%47 = load i8*, i8** %7
%48 = call i32 @ft_pute(double %45, i32* %46, i8* %47)
store i32 %48, i32* %4
br label %54
49: ; preds = %37
%50 = load double, double* %5
%51 = load i32*, i32** %6
%52 = load i8*, i8** %7
%53 = call i32 @ft_putf(double %50, i32* %51, i8* %52)
store i32 %53, i32* %4
br label %54
54: ; preds = %49, %44
%55 = load i32, i32* %4
ret i32 %55
}

LLVM IR (-O2):
define i32 @ft_putg(double %0, i32* %1, i8* %2) {
%4 = getelementptr inbounds i32, i32* %1, i64 1
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, -1
%7 = select i1 %6, i32 6, i32 %5
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 1, i32 %7
store i32 %9, i32* %4
%10 = tail call i32 @ft_gp(double %0)
%11 = icmp slt i32 %10, -3
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = tail call i32 @ft_gp(double %0)
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %18, label %16
16: ; preds = %12, %3
%17 = tail call i32 @ft_pute(double %0, i32* %1, i8* %2)
br label %20
18: ; preds = %12
%19 = tail call i32 @ft_putf(double %0, i32* %1, i8* %2)
br label %20
20: ; preds = %18, %16
%21 = phi i32 [ %17, %16 ], [ %19, %18 ]
ret i32 %21
}