#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 */
struct fsm {
  int dummy;
};

/* Variables and functions */
struct fsm *fsm_concat(struct fsm *, int /*<<< orphan*/);
int /*<<< orphan*/ fsm_copy(struct fsm *);
int /*<<< orphan*/ fsm_destroy(struct fsm *);
struct fsm *fsm_empty_string();
int /*<<< orphan*/ fsm_optionality(int /*<<< orphan*/);
struct fsm *fsm_concat_m_n(struct fsm *net1, int m, int n) {
  struct fsm *acc;
  int i;
  acc = fsm_empty_string();
  for (i = 1; i <= n; i++) {
    if (i > m)
      acc = fsm_concat(acc, fsm_optionality(fsm_copy(net1)));
    else
      acc = fsm_concat(acc, fsm_copy(net1));
  }
  fsm_destroy(net1);
  return (acc);
}


x86 assembly (clang, -O0):
<fsm_concat_m_n>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1060 <fsm_empty_string@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11eb <fsm_concat_m_n+0x9b>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11b8 <fsm_concat_m_n+0x68>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fsm_copy@plt>
mov    %eax,%edi
call   1050 <fsm_optionality@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1070 <fsm_concat@plt>
mov    %rax,-0x18(%rbp)
jmp    11d8 <fsm_concat_m_n+0x88>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fsm_copy@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1070 <fsm_concat@plt>
mov    %rax,-0x18(%rbp)
jmp    11dd <fsm_concat_m_n+0x8d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1174 <fsm_concat_m_n+0x24>
mov    -0x8(%rbp),%rdi
call   1040 <fsm_destroy@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsm_concat_m_n>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r14
xor    %eax,%eax
call   1060 <fsm_empty_string@plt>
mov    %rax,%rbp
test   %r12d,%r12d
jle    11b6 <fsm_concat_m_n+0x66>
neg    %r12d
mov    $0x1,%ebx
jmp    11a0 <fsm_concat_m_n+0x50>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %eax,%esi
call   1070 <fsm_concat@plt>
mov    %rax,%rbp
lea    (%r12,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     11b6 <fsm_concat_m_n+0x66>
mov    %r14,%rdi
call   1030 <fsm_copy@plt>
cmp    %r15d,%ebx
jle    1180 <fsm_concat_m_n+0x30>
mov    %eax,%edi
call   1050 <fsm_optionality@plt>
jmp    1180 <fsm_concat_m_n+0x30>
mov    %r14,%rdi
call   1040 <fsm_destroy@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.fsm = type { i32 }
define %struct.fsm* @fsm_concat_m_n(%struct.fsm* %0, i32 %1, i32 %2) {
%4 = alloca %struct.fsm*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.fsm*
%8 = alloca i32
store %struct.fsm* %0, %struct.fsm** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = call %struct.fsm* (...) @fsm_empty_string()
store %struct.fsm* %9, %struct.fsm** %7
store i32 1, i32* %8
br label %10
10: ; preds = %30, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i32, i32* %8
%16 = load i32, i32* %5
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load %struct.fsm*, %struct.fsm** %7
%20 = load %struct.fsm*, %struct.fsm** %4
%21 = call i32 @fsm_copy(%struct.fsm* %20)
%22 = call i32 @fsm_optionality(i32 %21)
%23 = call %struct.fsm* @fsm_concat(%struct.fsm* %19, i32 %22)
store %struct.fsm* %23, %struct.fsm** %7
br label %29
24: ; preds = %14
%25 = load %struct.fsm*, %struct.fsm** %7
%26 = load %struct.fsm*, %struct.fsm** %4
%27 = call i32 @fsm_copy(%struct.fsm* %26)
%28 = call %struct.fsm* @fsm_concat(%struct.fsm* %25, i32 %27)
store %struct.fsm* %28, %struct.fsm** %7
br label %29
29: ; preds = %24, %18
br label %30
30: ; preds = %29
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %10
33: ; preds = %10
%34 = load %struct.fsm*, %struct.fsm** %4
%35 = call i32 @fsm_destroy(%struct.fsm* %34)
%36 = load %struct.fsm*, %struct.fsm** %7
ret %struct.fsm* %36
}

LLVM IR (-O2):
%struct.fsm = type { i32 }
define %struct.fsm* @fsm_concat_m_n(%struct.fsm* %0, i32 %1, i32 %2) {
%4 = tail call %struct.fsm* (...) @fsm_empty_string()
%5 = icmp slt i32 %2, 1
br i1 %5, label %18, label %6
6: ; preds = %3, %13
%7 = phi i32 [ %16, %13 ], [ 1, %3 ]
%8 = phi %struct.fsm* [ %15, %13 ], [ %4, %3 ]
%9 = icmp sgt i32 %7, %1
%10 = tail call i32 @fsm_copy(%struct.fsm* %0)
br i1 %9, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @fsm_optionality(i32 %10)
br label %13
13: ; preds = %6, %11
%14 = phi i32 [ %12, %11 ], [ %10, %6 ]
%15 = tail call %struct.fsm* @fsm_concat(%struct.fsm* %8, i32 %14)
%16 = add nuw i32 %7, 1
%17 = icmp eq i32 %7, %2
br i1 %17, label %18, label %6
18: ; preds = %13, %3
%19 = phi %struct.fsm* [ %4, %3 ], [ %15, %13 ]
%20 = tail call i32 @fsm_destroy(%struct.fsm* %0)
ret %struct.fsm* %19
}