#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 t_irc_server {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ irc_server_sendf(struct t_irc_server *, int /*<<< orphan*/,
                                    char *, char *);
char *malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *);
int /*<<< orphan*/ strcat(char *, char const *);
int strlen(char const *);
void irc_command_mode_nicks(struct t_irc_server *server, const char *channel,
                            const char *set, const char *mode, int argc,
                            char **argv) {
  int i, length;
  char *command;
  length = 0;
  for (i = 1; i < argc; i++)
    length += strlen(argv[i]) + 1;
  length += strlen(channel) + (argc * strlen(mode)) + 32;
  command = malloc(length);
  if (command) {
    snprintf(command, length, "MODE %s %s", channel, set);
    for (i = 1; i < argc; i++)
      strcat(command, mode);
    for (i = 1; i < argc; i++) {
      strcat(command, " ");
      strcat(command, argv[i]);
    }
    irc_server_sendf(server, 0, "%s", command);
    free(command);
  }
}


x86 assembly (clang, -O0):
<irc_command_mode_nicks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11c2 <irc_command_mode_nicks+0x62>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118e <irc_command_mode_nicks+0x2e>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x48(%rbp),%ecx
mov    %eax,%edx
mov    -0x44(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
add    $0x20,%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     12b8 <irc_command_mode_nicks+0x158>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xde0(%rip),%rdx
call   1060 <snprintf@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1253 <irc_command_mode_nicks+0xf3>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    122c <irc_command_mode_nicks+0xcc>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1299 <irc_command_mode_nicks+0x139>
mov    -0x40(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1080 <strcat@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    125a <irc_command_mode_nicks+0xfa>
mov    -0x8(%rbp),%rdi
mov    -0x40(%rbp),%rcx
xor    %esi,%esi
lea    0xd5e(%rip),%rdx
call   1040 <irc_server_sendf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_command_mode_nicks>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r13
mov    %r8d,%r15d
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rdi,0x10(%rsp)
mov    $0x20,%ebx
cmp    $0x2,%r8d
mov    %rsi,(%rsp)
jl     11c4 <irc_command_mode_nicks+0x64>
mov    %r14,0x8(%rsp)
mov    %r15d,%ebp
xor    %ebx,%ebx
mov    $0x1,%r14d
xchg   %ax,%ax
mov    0x0(%r13,%r14,8),%rdi
call   1050 <strlen@plt>
add    %eax,%ebx
add    $0x1,%ebx
add    $0x1,%r14
cmp    %r14,%rbp
jne    11a0 <irc_command_mode_nicks+0x40>
add    $0x20,%ebx
mov    0x8(%rsp),%r14
mov    (%rsp),%rsi
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1050 <strlen@plt>
imul   %r15d,%eax
add    %ebx,%ebp
add    %eax,%ebp
mov    %ebp,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     129d <irc_command_mode_nicks+0x13d>
mov    %rax,%rbx
lea    0xe08(%rip),%rdx
mov    %rax,%rdi
mov    %ebp,%esi
mov    (%rsp),%rcx
mov    %r14,%r8
call   1060 <snprintf@plt>
cmp    $0x2,%r15d
jl     1271 <irc_command_mode_nicks+0x111>
lea    -0x1(%r15),%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
add    $0xffffffff,%ebp
jne    1220 <irc_command_mode_nicks+0xc0>
cmp    $0x2,%r15d
jl     1271 <irc_command_mode_nicks+0x111>
mov    %r15d,%r15d
mov    $0x1,%ebp
lea    0xdc6(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
mov    0x0(%r13,%rbp,8),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1250 <irc_command_mode_nicks+0xf0>
lea    0xd90(%rip),%rdx
mov    0x10(%rsp),%rdi
xor    %esi,%esi
mov    %rbx,%rcx
call   1040 <irc_server_sendf@plt>
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.t_irc_server = type { i32 }
@.str = [11 x i8] c"MODE %s %s\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"%s\00"
define void @irc_command_mode_nicks(%struct.t_irc_server* %0, i8* %1, i8* %2, i8* %3, i32 %4, i8** %5) {
%7 = alloca %struct.t_irc_server*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
store %struct.t_irc_server* %0, %struct.t_irc_server** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i8** %5, i8*** %12
store i32 0, i32* %14
store i32 1, i32* %13
br label %16
16: ; preds = %30, %6
%17 = load i32, i32* %13
%18 = load i32, i32* %11
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %33
20: ; preds = %16
%21 = load i8**, i8*** %12
%22 = load i32, i32* %13
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @strlen(i8* %25)
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %14
%29 = add nsw i32 %28, %27
store i32 %29, i32* %14
br label %30
30: ; preds = %20
%31 = load i32, i32* %13
%32 = add nsw i32 %31, 1
store i32 %32, i32* %13
br label %16
33: ; preds = %16
%34 = load i8*, i8** %8
%35 = call i32 @strlen(i8* %34)
%36 = load i32, i32* %11
%37 = load i8*, i8** %10
%38 = call i32 @strlen(i8* %37)
%39 = mul nsw i32 %36, %38
%40 = add nsw i32 %35, %39
%41 = add nsw i32 %40, 32
%42 = load i32, i32* %14
%43 = add nsw i32 %42, %41
store i32 %43, i32* %14
%44 = load i32, i32* %14
%45 = call i8* @malloc(i32 %44)
store i8* %45, i8** %15
%46 = load i8*, i8** %15
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %89
48: ; preds = %33
%49 = load i8*, i8** %15
%50 = load i32, i32* %14
%51 = load i8*, i8** %8
%52 = load i8*, i8** %9
%53 = call i32 @snprintf(i8* %49, i32 %50, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %51, i8* %52)
store i32 1, i32* %13
br label %54
54: ; preds = %62, %48
%55 = load i32, i32* %13
%56 = load i32, i32* %11
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %65
58: ; preds = %54
%59 = load i8*, i8** %15
%60 = load i8*, i8** %10
%61 = call i32 @strcat(i8* %59, i8* %60)
br label %62
62: ; preds = %58
%63 = load i32, i32* %13
%64 = add nsw i32 %63, 1
store i32 %64, i32* %13
br label %54
65: ; preds = %54
store i32 1, i32* %13
br label %66
66: ; preds = %80, %65
%67 = load i32, i32* %13
%68 = load i32, i32* %11
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %83
70: ; preds = %66
%71 = load i8*, i8** %15
%72 = call i32 @strcat(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%73 = load i8*, i8** %15
%74 = load i8**, i8*** %12
%75 = load i32, i32* %13
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = call i32 @strcat(i8* %73, i8* %78)
br label %80
80: ; preds = %70
%81 = load i32, i32* %13
%82 = add nsw i32 %81, 1
store i32 %82, i32* %13
br label %66
83: ; preds = %66
%84 = load %struct.t_irc_server*, %struct.t_irc_server** %7
%85 = load i8*, i8** %15
%86 = call i32 @irc_server_sendf(%struct.t_irc_server* %84, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %85)
%87 = load i8*, i8** %15
%88 = call i32 @free(i8* %87)
br label %89
89: ; preds = %83, %33
ret void
}

LLVM IR (-O2):
%struct.t_irc_server = type { i32 }
@.str = [11 x i8] c"MODE %s %s\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"%s\00"
define void @irc_command_mode_nicks(%struct.t_irc_server* %0, i8* %1, i8* %2, i8* %3, i32 %4, i8** nocapture %5) {
%7 = icmp sgt i32 %4, 1
br i1 %7, label %8, label %22
8: ; preds = %6
%9 = zext i32 %4 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 1, %8 ], [ %18, %10 ]
%12 = phi i32 [ 0, %8 ], [ %17, %10 ]
%13 = getelementptr inbounds i8*, i8** %5, i64 %11
%14 = load i8*, i8** %13
%15 = tail call i32 @strlen(i8* %14)
%16 = add i32 %12, 1
%17 = add i32 %16, %15
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %20, label %10
20: ; preds = %10
%21 = add i32 %17, 32
br label %22
22: ; preds = %20, %6
%23 = phi i32 [ 32, %6 ], [ %21, %20 ]
%24 = tail call i32 @strlen(i8* %1)
%25 = tail call i32 @strlen(i8* %3)
%26 = mul nsw i32 %25, %4
%27 = add i32 %23, %24
%28 = add i32 %27, %26
%29 = tail call i8* @malloc(i32 %28)
%30 = icmp eq i8* %29, null
br i1 %30, label %52, label %31
31: ; preds = %22
%32 = tail call i32 @snprintf(i8* %29, i32 %28, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
br i1 %7, label %36, label %49
33: ; preds = %36
br i1 %7, label %34, label %49
34: ; preds = %33
%35 = zext i32 %4 to i64
br label %41
36: ; preds = %31, %36
%37 = phi i32 [ %39, %36 ], [ 1, %31 ]
%38 = tail call i32 @strcat(i8* %29, i8* %3)
%39 = add nuw nsw i32 %37, 1
%40 = icmp eq i32 %39, %4
br i1 %40, label %33, label %36
41: ; preds = %34, %41
%42 = phi i64 [ 1, %34 ], [ %47, %41 ]
%43 = tail call i32 @strcat(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%44 = getelementptr inbounds i8*, i8** %5, i64 %42
%45 = load i8*, i8** %44
%46 = tail call i32 @strcat(i8* %29, i8* %45)
%47 = add nuw nsw i64 %42, 1
%48 = icmp eq i64 %47, %35
br i1 %48, label %49, label %41
49: ; preds = %41, %31, %33
%50 = tail call i32 @irc_server_sendf(%struct.t_irc_server* %0, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%51 = tail call i32 @free(i8* %29)
br label %52
52: ; preds = %49, %22
ret void
}